def test_contact(browser, contact_message_data): main_page = DemoMainPage(browser) main_page.navigate_to_contact() ContactFormPage(browser).send_message( contact_email=contact_message_data['contact_email'], contact_name=contact_message_data['contact_name'], message=contact_message_data['message']) wait_for_alert_and_accept(browser, 5)
def test_cart_button_after_login(browser, test_creds): main_page = DemoMainPage(browser) main_page.navigate_lo_login_page() LoginPage(browser).enter_valid_credentials(login=test_creds["login"], password=test_creds["password"]) WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.ID, "cartur"))) DemoMainPage(browser).navigate_to_cart()
def test_logout_button(browser, test_creds): main_page = DemoMainPage(browser) main_page.navigate_lo_login_page() LoginPage(browser).enter_valid_credentials(login=test_creds["login"], password=test_creds["password"]) WebDriverWait(browser, 10).until( EC.visibility_of_element_located((By.XPATH, "//a[.='Log out']"))) DemoMainPage(browser, registered=True).push_logout_button()
def test_add_cart_item(browser, test_creds): main_page = DemoMainPage(browser) main_page.navigate_lo_login_page() LoginPage(browser).enter_valid_credentials(login=test_creds["login"], password=test_creds["password"]) DemoMainPage(browser).navigate_to_phones_category() PhonesCategory(browser).navigate_to_nokia_lumia_product() EachProductClass(browser).add_product_to_cart() wait_for_alert_and_accept(browser, 10)
def test_login_into_account(browser, user): main_page = DemoMainPage(browser) main_page.navigate_to_signup_page() SignUpPage(browser).enter_valid_credentials(login=user["login"], password=user["password"]) wait_for_alert_and_accept(browser, 5) alert = browser.switch_to.alert alert.accept() main_page.navigate_lo_login_page() LoginPage(browser).enter_valid_credentials(login=user["login"], password=user["password"]) wait_for_element_be_located(browser, 10, 'nameofuser') assert DemoMainPage( browser, registered=True).welcome_label.text == f"Welcome {user['login']}"
def test_make_an_order(browser, order_info, test_creds): main_page = DemoMainPage(browser) main_page.navigate_lo_login_page() main_page = LoginPage(browser).enter_valid_credentials( login=test_creds["login"], password=test_creds["password"]) main_page.navigate_to_cart() WebDriverWait(browser, 10).until( EC.visibility_of_element_located( (By.XPATH, "//td[.='Nokia lumia 1520']"))) CartPage(browser).click_on_place_order() OrderPage(browser).enter_order_data(name=order_info['name'], city=order_info['city'], country=order_info['country'], credit_card=order_info['credit_card'], month=order_info['month'], year=order_info['year']) OrderPage(browser).click_purchase_button()
def enter_valid_credentials(self, login, password): wait = WebDriverWait(self.browser, 2) self.login_input.send_keys(login) try: wait.until( EC.text_to_be_present_in_element_value( (By.ID, "loginusername"), login)) except TimeoutException: self.login_input.send_keys(login) self.password_input.send_keys(password) try: wait.until( EC.text_to_be_present_in_element_value( (By.ID, "loginpassword"), password)) except TimeoutException: self.password_input.send_keys(password) self.enter_button.click() wait.until(EC.element_to_be_clickable( (By.XPATH, "//a[@id='logout2']"))) return DemoMainPage(self.browser)
def test_check_monitors_category(browser): DemoMainPage(browser).navigate_to_monitors_category() MonitorsCategory(browser)
def test_check_laptops_category(browser): DemoMainPage(browser).navigate_to_laptops_category() LaptopsCategory(browser)
def test_categories_navigation(browser): main_page = DemoMainPage(browser) main_page.navigate_to_phones_category() main_page.navigate_to_laptops_category() main_page.navigate_to_monitors_category()
def test_next_previous_category_buttons(browser): main_page = DemoMainPage(browser) main_page.push_next_category_page() main_page.push_previous_category_page()
def test_cart_button(browser): main_page = DemoMainPage(browser) main_page.navigate_to_cart()
def test_about_us(browser): main_page = DemoMainPage(browser) main_page.navigate_to_about_us() AboutUsPage(browser).push_play_button() AboutUsPage(browser).push_close_button()
def test_check_phones_category(browser): DemoMainPage(browser).navigate_to_phones_category() PhonesCategory(browser)