def login(driver): #check loged in user page = ProductPage() modal = Modal() page.click_my_orders() modal.click_sign_in() modal.login(email, password)
def test_message_disappeared_after_adding_product_to_basket(browser): link = 'http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/' item_page = ProductPage(browser, link) item_page.open() item_page.add_to_card() item_page.is_disappeared( *ProductPageLocators.SUCCESS_ADD_PRODUCT_TO_BASKET_TEXT)
def test_guest_cant_see_success_message_after_adding_product_to_basket( browser): link = 'http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/' item_page = ProductPage(browser, link) item_page.open() item_page.add_to_card() item_page.is_not_element_present( *ProductPageLocators.SUCCESS_ADD_PRODUCT_TO_BASKET_TEXT)
def test_e2e_functionality(self): home_page = HomePage(self.driver) search_page = SearchPage(self.driver) product_page = ProductPage(self.driver) home_page.get_search_box().send_keys("laptop") home_page.get_search_icon().click() search_page.get_first_item_price_element().click() main_window = self.driver.window_handles[0] child_window = self.driver.window_handles[1] self.driver.switch_to.window(child_window) assert product_page.get_add_to_card_button().is_displayed() assert product_page.get_buy_now_button().is_displayed() assert "buy now" in product_page.get_buy_now_button( ).find_element_by_xpath("parent::span/span").text.lower() assert "add to cart" in product_page.get_add_to_card_button( ).get_attribute('value').lower() self.driver.close() self.driver.switch_to.window(main_window)
def test_is_product_page_open(self): self.login_page = LoginPage(self.driver) self.login_page.login(TestData.STANDARD_USER, TestData.PASSWORD) self.product_page = ProductPage(self.driver) self.product_page.is_logo_exist() assert self.product_page.get_subheader() == "PRODUCTS"
class TestProductPage(BaseTest): def test_is_product_page_open(self): self.login_page = LoginPage(self.driver) self.login_page.login(TestData.STANDARD_USER, TestData.PASSWORD) self.product_page = ProductPage(self.driver) self.product_page.is_logo_exist() assert self.product_page.get_subheader() == "PRODUCTS" def test_sort_products_a_to_z(self): self.login_page = LoginPage(self.driver) self.login_page.login(TestData.STANDARD_USER, TestData.PASSWORD) self.product_page = ProductPage(self.driver) self.product_page.click_sort_menu() self.product_page.sort_a_to_z() def test_sort_products_z_to_a(self): self.login_page = LoginPage(self.driver) self.login_page.login(TestData.STANDARD_USER, TestData.PASSWORD) self.product_page = ProductPage(self.driver) self.product_page.click_sort_menu() self.product_page.sort_z_to_a() def test_sort_low_products_to_high(self): self.login_page = LoginPage(self.driver) self.login_page.login(TestData.STANDARD_USER, TestData.PASSWORD) self.product_page = ProductPage(self.driver) self.product_page.click_sort_menu() self.product_page.sort_low_to_high() def test_sort_products_high_to_low(self): self.login_page = LoginPage(self.driver) self.login_page.login(TestData.STANDARD_USER, TestData.PASSWORD) self.product_page = ProductPage(self.driver) self.product_page.click_sort_menu() self.product_page.sort_high_to_low() # TODO: this test will be in test_cart_page.py def test_abc_xyz(self): self.login_page = LoginPage(self.driver) self.login_page.login(TestData.STANDARD_USER, TestData.PASSWORD) self.product_page = ProductPage(self.driver) self.product_page.add_all_to_cart( ) # it works but i need find another solution
def test_abc_xyz(self): self.login_page = LoginPage(self.driver) self.login_page.login(TestData.STANDARD_USER, TestData.PASSWORD) self.product_page = ProductPage(self.driver) self.product_page.add_all_to_cart( ) # it works but i need find another solution
def test_sort_products_high_to_low(self): self.login_page = LoginPage(self.driver) self.login_page.login(TestData.STANDARD_USER, TestData.PASSWORD) self.product_page = ProductPage(self.driver) self.product_page.click_sort_menu() self.product_page.sort_high_to_low()
def test_07_add_to_basket(self): print("\n" + str(test_cases(6))) driver = self.driver page = ProductPage(driver) page.addToBasket() time.sleep(5)
def get_first_product_result(self): WebdriverWaits.wait_for_element_visible(self.driver, 5, self.__first_product_result_locator).click() return ProductPage(self.driver)
def test_productpage(browser): product_page = ProductPage(browser) product_page.open_product_page() product_page.check_elements_on_product_page()
def test_guest_should_see_login_link_on_product_page(self, browser): link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/" page = ProductPage(browser, link) page.open() page.should_be_login_link()
def test_sign_out(self, login): page = ProductPage() sleep(2) page.hover_burger_menu() page.sign_out()