Esempio n. 1
0
    def routing(self, request):
        """
        ルーティング
        """
        route = request.getvalue('Route', ['top'])
        session = request.getvalue('Session', None)
        setting = request.getvalue('Setting', {})
        post = request.getvalue('Post', MyStrage())

        # ルーティング情報がなければデフォルトをセット
        if route[0] == '':
            route = ['top']
        if len(route)<2:
            route.append('index')
        elif route[1]=='':
            route[1] = 'index'

        page = route[0]
        method = route[1]
        param = []
        for i in range(len(route)-2):
            param.append(route[i+2])

        # ページクラスを取得
        response_page = None
        try:
            # ページクラスを動的インポート
            page_class_name = page.capitalize()+'Page'
            page_class = getattr(__import__('page.'+page, {}, {}, page_class_name), page_class_name)
            response_page = page_class(request)
        except:
            import sys
            import traceback
            info = sys.exc_info()
            self.error_info.append([info, traceback.format_tb(info[2])[0]])
            response_page = None

        # ページクラスが読み込めなければ未実装と判定
        if response_page is None:
            from page.page import Page
            response_page = Page(request)

        # ページからメソッド取得
        try:
            response_method = getattr(response_page, method)
            page_data = response_method(param)
        except:
            import sys
            import traceback
            info = sys.exc_info()
            self.error_info.append([info, traceback.format_tb(info[2])])
            response_method = getattr(response_page, 'error')
            page_data = response_method(param)

        self.title = response_page.get_title()

        return page_data
Esempio n. 2
0
 def setup(self):
     self.driver = init_driver(noReset=True)
     self.page = Page(self.driver)
Esempio n. 3
0
 def setup(self):
     self.driver = init_driver()
     self.page = Page(self.driver)
Esempio n. 4
0
 def setUpClass(cls):
     cls.page = Page()
     cls.page.open('http://www.lawnewscn.com/')
Esempio n. 5
0
 def setup(self):
     self.driver = BaseDriver.init_driver()
     self.page = Page(self.driver)
Esempio n. 6
0
 def setup_class(self):
     self.driver=Initdriver()
     self.page=Page(self.driver).page_address()
     print("开始了!!!")
Esempio n. 7
0
    def setup(self):
        self.driver = BaseDriver.init_driver()

        # self.base_action = BaseAction(self.driver)
        self.page = Page(self.driver)
Esempio n. 8
0
class Test_login:
    def setup_class(self):
        # self.page_obj = Page(get_driver("com.yunmall.lc","com.yunmall.ymctoc.ui.activity.MainActivity"))
        self.page_obj1 = Page(get_driver())

    def teardown_class(self):
        self.page_obj1.driver.quit()

    # @pytest.mark.parametrize("test_num,phone,passwd,tag,tag_message,expect_result", get_login_data())
    # def test_001_001(self,test_num,phone,passwd,tag,tag_message,expect_result):
    #     self.page_obj1.get_home_obj().click_my_btn()
    #     self.page_obj1.get_sign_obj().click_exists_btn()
    #     self.page_obj1.get_login_obj().login_user(phone, passwd)
    #     if tag:
    #         try:
    #             assert expect_result in self.page_obj1.get_person_obj().person_coupons()
    #             self.page_obj1.get_person_obj().get_setting()
    #             self.page_obj1.get_setting_obj().login_out(tag)
    #
    #         except:
    #             assert False
    #     else:
    #         try:
    #             assert expect_result in self.page_obj1.get_setting_obj().get_toast(tag_message)
    #         except:
    #             assert False
    #         finally:
    #             self.page_obj1.get_login_obj().out_btn_user()

# if __name__ == '__main__':
#     pytest.main("-s test_01.py")

    @pytest.mark.parametrize(
        "test_num,phone,passwd,tag,tag_message,expect_result",
        get_login_data())
    def test_login(self, test_num, phone, passwd, tag, tag_message,
                   expect_result):
        """
        :param test_num: 用例编号
        :param phone: 输入手机号
        :param passwd: 输入密码
        :param tag: 标记成功用例 1 成功用例  None 失败用例
        :param tag_message: 获取toast消息方法参数
        :param expect_result:预期结果
        :return:
        """
        # 点击我
        self.page_obj1.get_home_obj().click_my_btn()
        self.page_obj1.get_sign_obj().click_exists_btn()
        self.page_obj1.get_login_obj().login_user(phone, passwd)
        # 判断成功失败用例
        if tag:
            # 预期成功用例
            try:
                # 优惠券
                coupons = self.page_obj1.get_person_obj().person_coupons()
                try:
                    # 断言
                    assert coupons == expect_result
                except AssertionError as e:
                    print(e.__str__())
                # 执行退出操作
                # 点击设置
                self.page_obj1.get_person_obj().get_setting()
                time.sleep(3)
                self.page_obj1.get_setting_obj().login_out(1)

            except TimeoutException as e:
                # 关闭登录页面
                self.page_obj1.get_login_obj().out_btn_user()
                assert False

        else:
            # 预期失败的用例
            try:
                # 获取toast消息
                toast_message = self.page_obj1.get_setting_obj().get_toast(
                    tag_message)
                # 获取登录按钮是否存在
                if_login = self.page_obj1.get_login_obj().if_login_btn_exits()
                # 断言
                assert if_login and toast_message == expect_result

            except TimeoutException as e:
                assert False

            finally:
                # 关闭登录页面
                self.page_obj1.get_login_obj().out_btn_user()
Esempio n. 9
0
 def setup(self):
     # 实例 int_driver
     self.driver = int_driver()
     #实例化一个page   这个一个大的入口
     self.page = Page(self.driver)
Esempio n. 10
0
 def setup_class(self):
     # 获取driver
     self.driver = GetDriver.get_web_driver(page.mis_url)
     # 获取PageMisLogin对象
     self.login = Page(self.driver).page_get_PageMisLogin()
Esempio n. 11
0
 def _sheet(self) -> WebElement:
     return Page.find_element((MobileBy.CLASS_NAME, XCUIElementType.Sheet))
Esempio n. 12
0
import time

from selenium.webdriver.common.by import By
from base.Base import Base
from page.page import Page
from base.get_driver import get_driver

page_obj = Page(
    get_driver("com.yunmall.lc",
               "com.yunmall.ymctoc.ui.activity.MainActivity"))
page_obj.get_index_page().click_me_btn()
page_obj.get_choose_login_page().click_login_btn()
time.sleep(1)
page_obj.login_page().login("18701878226", "air2111960")
# 获取toast消息
# mess_path = (By.XPATH, "//*contains[@text,'登录密码错误']")
# print(page_obj.login_page().get_element(mess_path).text)
print(page_obj.login_page().get_toast("登录密码错误"))
# time.sleep(2)
# print(page_obj.get_personal_page().get_collect())
# page_obj.get_personal_page().click_setting_btn()
# page_obj.get_setting_page().setting_quit()
# page_obj.driver.quit()
 def setup_class(self):
     self.driver = GetDriver.get_web_driver(page.index_url)
     self.pencil = Page(self.driver).page_get_PageIndexPencil()
class TestIndexPencil:

    # 初始化
    def setup_class(self):
        self.driver = GetDriver.get_web_driver(page.index_url)
        self.pencil = Page(self.driver).page_get_PageIndexPencil()

    # 结束
    @staticmethod
    def teardown_class():
        GetDriver.close_web_driver()

    def test_index_pencil(self):
        try:
            # 铅笔绘画组合方法
            self.pencil.page_index_draw_pencil()
            self.pencil.base_get_assert_img()
            # 绘画删除组合方法
            self.pencil.page_index_delete_draw_pencil()
            self.pencil.base_get_assert_img()
            # 铅笔默认属性更改
            self.pencil.page_index_property_pencil()
            self.pencil.base_get_assert_img()
        except Exception as e:
            # 日志
            log.error(e)
            # 抛异常
            raise
Esempio n. 15
0
    def setup(self):
        self.driver = init_driver()
        self.page = Page(self.driver)
		print("aaa")
Esempio n. 16
0
def page(driver: WebDriver) -> None:
    logging.debug(f"providing Page class with driver")
    Page.inject_driver(driver)
Esempio n. 17
0
class TestLogin():
    def setup_class(self):
        self.page_obj = Page(get_driver("com.yunmall.lc", "com.yunmall.ymctoc.ui.activity.MainActivity"))

    def teardown_class(self):
        self.page_obj.driver.quit()

    @pytest.fixture(autouse=True)
    def go_to_login(self):
        self.page_obj.get_index_page().click_me_btn()
        self.page_obj.get_choose_login_page().click_login_btn()
        time.sleep(1)

    @pytest.mark.parametrize(" test_no,,user, passwd,except_data", get_data().get("success"))
    def test_login_success(self, test_no, user, passwd, except_data):
        self.page_obj.login_page().login(user, passwd)
        try:
            # 获取我的收藏
            my_collect = self.page_obj.get_personal_page().get_collect()
            try:
                # 断言
                assert my_collect == except_data
            #   断言成功,点击设置,退出
            except AssertionError:
                # 断言失败
                # 截图
                self.page_obj.login_page().get_picture()
                print(test_no)
                assert False
            finally:
                #  点击设置,退出
                self.page_obj.get_personal_page().click_setting_btn()
                self.page_obj.get_setting_page().setting_quit()

        except TimeoutException:
            print("失败")
            # """失败情况"""
            # 截图
            self.page_obj.login_page().get_picture()
            # 关掉登录页面
            self.page_obj.login_page().close_login_page()
            print(test_no)
            assert False

    @pytest.mark.parametrize(" test_no,,user, passwd,toast,except_data", get_data().get("fail"))
    def test_login_fail(self, test_no, user, passwd, toast, except_data):
        self.page_obj.login_page().login(user, passwd)
        try:
            # """找到toast"""
            # 获取toast消息
            toast_text = self.page_obj.login_page().get_toast(toast)
            try:
                assert toast_text == except_data
            except AssertionError:
                self.page_obj.login_page().get_picture()
                assert False

        except TimeoutException:
            self.page_obj.login_page().get_picture()
            assert False
        finally:
            try:
                # 判断登录按钮
                self.page_obj.login_page().get_login_btn()
                # 关闭登录按钮
                self.page_obj.login_page().close_login_page()

            except TimeoutException:
                self.page_obj.get_personal_page().click_setting_btn()
                # 截图
                self.page_obj.login_page().get_picture()
                self.page_obj.get_setting_page().setting_quit()
                assert False
Esempio n. 18
0
class TestLogin(object):

    def setup_class(self):
        self.driver = get_phone_driver("com.yunmall.lc",
                                       "com.yunmall.ymctoc.ui.activity.MainActivity")
        self.page = Page(self.driver)

    def teardown_class(self):
        self.driver.quit()

    @pytest.fixture(autouse=True)
    def auto_in_login(self):
        # 主页点击我
        self.page.home_page().click_my()
        # 点击已注册账户登录
        self.page.sign_page().click_login_page()

    @pytest.mark.parametrize("account,pwd,expect_data", get_login_data().get("suc"))
    def test_login(self, account, pwd, expect_data):
        # # 主页点击我
        # self.page.home_page().click_my()
        # # 点击已注册账户登录
        # self.page.sign_page().click_login_page()

        # 输入登录信息
        self.page.login_page().login_page(account, pwd)
        # 判断登录与否
        try:
            # 获取我的优惠
            shop_cart = self.page.person_page().get_shop_cart()
            try:
                assert shop_cart == expect_data
            except AssertionError:
                # 截图并创建allure
                self.page.person_page().screen_page()
                assert False
            finally:
                # 点击设置按钮
                self.page.person_page().click_setting()
                # 退出账号
                self.page.setting_page().go_to_logout()
        except TimeoutException:
            # 截图并创建allure
            self.page.person_page().screen_page()
            # 返回首页
            self.page.login_page().login_close_page()
            assert False

    @pytest.mark.parametrize("account,pwd,expect_data,toast", get_login_data().get("fail"))
    def test_login_is_no(self, account, pwd, expect_data, toast):
        # # 主页点击我
        # self.page.home_page().click_my()
        # # 点击已注册账户登录
        # self.page.sign_page().click_login_page()

        # 输入登录信息
        self.page.login_page().login_page(account, pwd)
        # 判断登录与否
        try:
            # 判断toast消息
            # 截图 查看toast消息
            self.page.person_page().screen_page()
            toast_test = self.page.person_page().get_toast(toast)
            # print("toast:{},expect_toast{}".format(toast, toast_test))
            try:
                # 判断登录按钮
                self.page.login_page().if_login_but()

                assert toast_test == toast
                # 放回首页
                self.page.setting_page().go_to_logout()

            except TimeoutException:
                # 截图并创建allure
                self.page.person_page().screen_page()
                # # 点击设置按钮
                self.page.person_page().click_setting()
                # 退出账号
                self.page.setting_page().go_to_logout()
                assert False

            except AssertionError:
                # 截图并创建allure
                self.page.person_page().screen_page()
                # 返回首页
                self.page.login_page().login_close_page()
                assert False

        except TimeoutException:
            # 截图并创建allure
            self.page.person_page().screen_page()
            try:
                # 判断登录按钮
                self.page.login_page().if_login_but()
                # 返回首页
                self.page.login_page().login_close_page()

            except TimeoutException:
                # # 点击设置按钮
                self.page.person_page().click_setting()
                # 退出账号
                self.page.setting_page().go_to_logout()
            assert False
Esempio n. 19
0
 def setup_class(self):
     # self.page_obj = Page(get_driver("com.yunmall.lc","com.yunmall.ymctoc.ui.activity.MainActivity"))
     self.page_obj1 = Page(get_driver())
Esempio n. 20
0
 def setup_class(self):
     self.driver = get_phone_driver("com.yunmall.lc",
                                    "com.yunmall.ymctoc.ui.activity.MainActivity")
     self.page = Page(self.driver)
Esempio n. 21
0
class Test_(object):
    def setup_class(self):
        self.driver=Initdriver()
        self.page=Page(self.driver).page_address()
        print("开始了!!!")

    def teardown_class(self):
        time.sleep(6)
        self.driver.quit()
        print("结束了!!!")

    @pytest.fixture(scope="function")
    def start_address(self):
        self.page.click_address()

    @pytest.fixture(scope="class")
    def click_bdbc(self):
        self.page.click_bdbc()

    @pytest.mark.parametrize("expect", ["新增联系人"])
    def test_001(self,expect):
        self.page.click_address()
        self.page.click_bdbc()
        time.sleep(1)
        text_list=self.driver.page_source
        assert expect in text_list

    @pytest.mark.parametrize("expect", ["所有联系人"])
    def test_002(self,expect):
        self.page.out_address()
        time.sleep(1)
        text_list=self.driver.page_source
        assert expect in text_list

    @pytest.mark.usefixtures("start_address")
    @pytest.mark.parametrize("test_no,name,phone,expect",read_test_data())
    def test_003(self,test_no,name,phone,expect):
        print(test_no,name,phone,expect)
        self.page.send_message(name, phone)
        self.page.out_address()
        time.sleep(5)
        if name=="" and phone =="":
            pass
        else:
            self.page.out_keyevent()
        time.sleep(1)
        text_list=self.driver.page_source
        assert expect in text_list
 def setup_class(self):
     self.driver = GetDriver.get_web_driver(page.index_url)
     self.openfile = Page(self.driver).page_get_PageIndexOpenFile()
     self.pencil = Page(self.driver).page_get_PageIndexPencil()
     self.savefile = Page(self.driver).page_get_PageIndexSavefile()
Esempio n. 23
0
 def setup(self):
     self.driver = get_driver()
     self.page = Page(self.driver)
     self.page.page_home.login_if_not(self.page)
Esempio n. 24
0
 def setup(self):
     self.driver = web_driver()
     self.page = Page(self.driver)
Esempio n. 25
0
 def setup(self):
     self.driver = init_driver(no_reset=False)
     self.page=Page(self.driver)
Esempio n. 26
0
 def setUpClass(cls):
     warnings.simplefilter("ignore", ResourceWarning)
     cls.driver = GetDriver().get_driver()
     cls.page = Page(cls.driver)
     cls.page.page_home.click_login()
Esempio n. 27
0
 def setUpClass(cls):
     cls.page = Page()
Esempio n. 28
0
 def setup(self):
     self.page = Page()
     pass
Esempio n. 29
0
 def setUpClass(cls):
     cls.page = Page()
     cls.tool = Tool()
     # 重点!!! 每次测试之前需要删除报错的截图,不然成功的用例也会将错误图片放进去
     cls.tool.clear_picture()
Esempio n. 30
0
 def setup(self):
     logging.info("正在获取driver对象")
     self.driver = BaseDriver().get_driver()
     self.page = Page(self.driver)