Beispiel #1
0
def login(init_app):
    """登录的前置条件"""
    driver = init_app
    NavPage(driver).click_nav('我的柠檬')

    # 登录
    user_page = UserPage(driver)
    user_page.login(corrent_username, corrent_pwd)

    yield driver

    print("退出 login")
def test_add_to_watch_later(browser, auth):
    movie_page = MoviePage(browser, url="https://www.kinopoisk.ru/film/693969/")
    movie_page.open()
    movie_page.login(*auth)

    movie_page.add_to_watch_later()
    movie_name = movie_page.get_movie_name()
    movie_page.go_to_watch_later_list()
    user_page = UserPage(movie_page.driver, movie_page.driver.current_url)
    name = user_page.get_first_movie_in_watch_later_list()
    assert movie_name == name, f"Имена {movie_name} на странице фильма и {name} в списке 'Буду смотреть' не совпадают"

    result = user_page.del_first_from_watch_later()
    assert result is True, f"Фильм из списка не удален"
Beispiel #3
0
 def test_bid_03_success(self,succes_data,init_bid):
     # self.home_page.get()
     # self.home_page.click_bid_button()
     driver, login_page, home_page = init_bid
     bid_page=BidPage(driver)
     # bid_page.bid_input_money(succes_data['money'])
     bid_before_money= eval(bid_page.bid_succes(succes_data['money']))
     assert(bid_page.bid_success_msg_elem.text,succes_data['msg'])
     bid_page.click_bid_active_button()
     user_page=UserPage(driver)
     bid_after_money=user_page.get_avaiable_money()
     assert(bid_before_money-succes_data['money'],bid_after_money)
     driver.back()
     driver.refresh()
Beispiel #4
0
    def test_login_empty(self, test_info, init_app):
        """"测试为空"""
        # 1, 点击我的柠檬
        # 2, 点击头像登录
        # 3, 登录页面输入用户名和密码
        # 4, 断言
        driver = init_app
        # 进入我的柠檬
        NavPage(driver).click_nav('我的柠檬')

        # 登录
        user_page = UserPage(driver)
        user_page.login(test_info['mobile'], test_info['pwd'])
        # 断言
        assert user_page.get_elem_toast(test_info['expected'])
Beispiel #5
0
 def test_del_success(self, test_info, get_browser):
     driver = get_browser
     LoginPage(driver).login(User.username, User.pwd)
     print("-------执行删除用户测试用例----------")
     expected = test_info['expected']
     print("---------测试数据------------------")
     UserPage(driver).delUser(test_info["name"])
     success_msg = UserPage(driver).get_del_success_msg()
     print("---------断言结果------------")
     print("实际结果:", success_msg)
     print("预期结果:", expected)
     try:
         assert success_msg == expected
     except AssertionError as e:
         raise e
Beispiel #6
0
def invest_fixture():
    """投资用例的前置条件"""
    driver = create_driver()
    # 最大化窗口
    driver.maximize_window()
    # 设置隐式等待
    driver.implicitly_wait(15)
    # 实例登录页面对象
    login_page = LoginPage(driver)
    # 打开登录页面
    login_page.open_login_page()
    # 进行登录
    login_page.login(mobile_phone=conf.get('test_data', 'mobile'),
                     pwd=conf.get('test_data', 'pwd'))
    # 实例首页对象
    index_page = IndexPage(driver)
    # 首页点击投资
    index_page.click_invest()
    # 实例投资页面对象
    invest_page = InvestPage(driver)
    # 实例用户页面对象
    user_page = UserPage(driver)

    yield invest_page, user_page
    driver.quit()
Beispiel #7
0
def test_change_user(browser, user_change_config_data):
    user_email, user_password, \
    new_first_name, new_last_name = user_change_config_data
    main_page = MainPage(browser)
    main_page.open_base_page()
    main_page.login(user_email, user_password)

    user_page = UserPage(browser)
    user_page.button_edit_account_click()

    account_page = AccountPage(browser)
    account_page.change_firstname_field(new_first_name)
    account_page.change_lastname_field(new_last_name)
    account_page.save_change()

    check_change_user(new_first_name, new_last_name)
 def setUpClass(cls):
     cls.driver = webdriver.Chrome()
     cls.driver.get(url=url)
     cls.loginpage = LoginPage(driver=cls.driver)
     cls.loginpage.login()
     cls.homepage = HomePage(driver=cls.driver)
     cls.userpage = UserPage(driver=cls.driver)
     cls.investpage = InvesPage(driver=cls.driver)
Beispiel #9
0
    def setUp(self) -> None:
        """
        前置条件:
        1, 登录
        :return:
        """
        self.driver = webdriver.Chrome()
        # self.driver.save_screenshot()
        self.driver.implicitly_wait(20)

        # 初始化页面
        self.login_page = LoginPage(self.driver)
        self.index_page = IndexPage(self.driver)
        self.bid_page = BidPage(self.driver)
        self.user_page = UserPage(self.driver)

        # 登录
        login_data = login_data_success[0]
        self.login_page.login(login_data['mobile'], login_data['pwd'])
Beispiel #10
0
 def setUpClass(cls):
     caps = yaml.load(open("../config/init_app.yml", "r"),
                      Loader=yaml.FullLoader)
     cls.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
     cls.login_page = LoginPage(cls.driver)
     cls.home_page = HomePage(cls.driver)
     cls.user_page = UserPage(cls.driver)
     time.sleep(3)
     cls.home_page.welcome()
     cls.home_page.home_login()
Beispiel #11
0
def enter_bid_page(init_browser):
    login_page, home_page, browser = init_browser
    bid_page = BidPage(browser)
    user_page = UserPage(browser)
    login_page.login(login_success_data["phone"], login_success_data["pwd"])
    home_page.click_bid_button()

    yield bid_page, user_page

    browser.quit()
Beispiel #12
0
 def setUpClass(cls):
     logger.info("开始执行测试类")
     cls.desired = cls.conf.read_alone
     cls.desired["app"] = APK_PATH
     cls.driver = webdriver.Remote(
         command_executor="http://192.168.1.103:4723/wd/hub",
         desired_capabilities=cls.desired)
     cls.home_page = HomePage(cls.driver)
     cls.login_page = LoginPage(cls.driver)
     cls.loan_page = LoanPage(cls.driver)
     cls.user_page = UserPage(cls.driver)
     cls.invest_page = InvestPage(cls.driver)
     cls.register_page = RegisterPage(cls.driver)
Beispiel #13
0
 def test_invest_success(self, test_info):
     # 1、登录之后进入首页,先在首页点击抢投标按钮
     IndexPage(self.driver).get_invest_btn()
     # 2、投标,并获取投标前的金额
     invest_page = InvestPage(self.driver)
     money_before = invest_page.bid(test_info['money'])
     success_text = invest_page.bid_success()
     self.assertTrue(test_info['expected'] in success_text)
     # 3、点击查看并激活
     invest_page.active_success()
     # 4、获取投标后的金额
     money_after = UserPage(self.driver).get_money()
     # 5、断言
     self.assertEqual(Decimal(money_before) - Decimal(str(test_info['money'])), Decimal(money_after))
Beispiel #14
0
 def test_bid_success(self, success_data, bid_web):
     """投资成功的情况"""
     driver, login_page = bid_web
     home_page = HomePage(driver)
     home_page.get()
     home_page.click_bid_button()
     bid_page = BidPage(driver)
     # bid_page.bid_input.send_keys(success_data['amount'])
     # bid_page.bid_confirm_button.click()
     balance = bid_page.bid_success(success_data['amount'])
     assert success_data['expect'] == bid_page.bid_popup_msg_element.text
     # 验证余额
     bid_page.click_bid_active_button()
     actual_balance = UserPage(driver).get_balance()
     assert Decimal(balance) - Decimal(
         success_data['amount']) == Decimal(actual_balance)
Beispiel #15
0
 def test_01_success_bid(self, pass_data):
     home_page = HomePage(self.driver)
     home_page.get_url()
     home_page.click_bid()
     bid_page = BidPage(self.driver)
     balance = bid_page.bid(pass_data[0])
     try:
         self.assertEqual(bid_page.pass_msg_element(), pass_data[1])
         loger.info('投资金额为:{} 的测试用例执行成功!'.format(pass_data[0]))
     except AssertionError as e:
         loger.error('投资金额为:{} 的测试用例执行失败!'.format(pass_data[0]))
         raise e
     bid_page.click_active_element()
     after_balance = UserPage(self.driver).get_money()
     try:
         self.assertTrue(
             Decimal(balance) -
             Decimal(str(bid_pass_data[0] == Decimal(after_balance))))
         loger.info('投资金额为:{} 的测试用例执行成功!'.format(pass_data[0]))
     except AssertionError as e:
         loger.error('投资金额为:{} 的测试用例执行失败!'.format(pass_data[0]))
         raise e
Beispiel #16
0
 def click_active_btn(self):
     """点击查看并激活"""
     e = self.wait_element_clickable(self.active_btn_locator)
     e.click()
     return UserPage(self.driver)
Beispiel #17
0
 def click_active_btn(self):
     """点击查看并激活"""
     el = self.browser.find_element(*self.active_btn_locator)
     el.click()
     return UserPage(self.browser)
Beispiel #18
0
class TestBid(unittest.TestCase):
    def setUp(self) -> None:
        """
        前置条件:
        1, 登录
        :return:
        """
        self.driver = webdriver.Chrome()
        # self.driver.save_screenshot()
        self.driver.implicitly_wait(20)

        # 初始化页面
        self.login_page = LoginPage(self.driver)
        self.index_page = IndexPage(self.driver)
        self.bid_page = BidPage(self.driver)
        self.user_page = UserPage(self.driver)

        # 登录
        login_data = login_data_success[0]
        self.login_page.login(login_data['mobile'], login_data['pwd'])

    def tearDown(self) -> None:
        pass

    # def test_bid_error(self):
    #     "测试投资失败"
    #     time.sleep(1)
    #     self.index_page.get()
    #
    #     # 如果不等待新页面出现而直接定位元素,可能找到的是上一个页面当中的元素。
    #     self.index_page.get_element_bid().click()
    #
    #     # 定位投标输入框
    #     bid_element = self.bid_page.get_element_bid_input()
    #
    #     # 发送投标金额
    #     bid_element.send_keys("1")
    #
    #     # 获取实际结果
    #     actual = self.bid_page.get_element_bid_btn().text
    #     self.assertEqual(actual, '请输入10的整数倍')

    # PO
    def test_bid_success(self):
        """测试投资成功"""
        time.sleep(1)
        self.index_page.get()

        # 如果不等待新页面出现而直接定位元素,可能找到的是上一个页面当中的元素。
        self.index_page.get_element_bid().click()

        # 定位投标输入框
        bid_element = self.bid_page.get_element_bid_input()

        # 获取余额, 字符串
        money_before = bid_element.get_attribute("data-amount")

        # 发送投标金额
        bid_element.send_keys("100")

        self.bid_page.get_element_bid_btn().click()

        # 如何断言投资成功
        actual = self.bid_page.get_success_msg().text
        self.assertEqual(actual, '投标成功!')

        # 断言余额是否正确扣除,
        # 1, 获取投标之前的余额
        # 2, 获取投标之后的余额  ==
        self.bid_page.get_active_btn().click()
        # user 页面 获取投标之后的余额

        money_after = self.user_page.get_element_money().text[:-1]
        self.assertEqual(
            Decimal(money_before) - Decimal("100"), Decimal(money_after))