def get_wishlist_count(self): WebDriverWait(self.driver, 10).until( EC.invisibility_of_element_located( (By.XPATH, '//div[contains(@class, ' '"ScrollableArea__StyledScrollableContainer-v545jt-0 kVDQL")]' ))) return HomePage(self.driver).wishlist_count().text
class TestHomePage: lp = LoginPage() hp = HomePage() def testResetAppState(self): driver.execute_script( 'window.sessionStorage.setItem("cart-contents","[4,0,1]")') self.hp.burger_menu_open() self.hp.reset_app_button_click() self.hp.x_button_click() assert self.hp.shopping_cart_num_exist() assert self.hp.session_storage_is_empty() def testLogout(self): self.hp.burger_menu_open() self.hp.logout_button_click() assert self.lp.username_field_exist() assert self.lp.password_field_exist() assert self.lp.login_button_exist() def testAbout(self): driver.get("https://www.saucedemo.com/inventory.html") self.hp.burger_menu_open() self.hp.about_button_click() assert self.hp.check_about_url()
def login_to_fb(self, email, password): email_el = self.driver.find_element(*self.EMAIL_FIELD) email_el.send_keys(email) password_el = self.driver.find_element(*self.PASSWORD_FIELD) password_el.send_keys(password) self.driver.find_element(*self.LOGIN_BUTTON).click() return HomePage(self.driver)
class TestloginPage: lp = LoginPage() hp = HomePage() def testInvalidLogin(self): self.lp.set_username("standard_user") self.lp.set_password("wrong_pass") self.lp.login_button_click() assert self.lp.error_button_exist() assert self.lp.message_credentials_not_match_exist() def testLockedOutLogin(self): self.lp.set_username("locked_out_user") self.lp.set_password("secret_sauce") self.lp.login_button_click() assert self.lp.error_button_exist() assert self.lp.message_user_locked_out_exist() def testValidLogin(self): self.lp.set_username("standard_user") self.lp.set_password("secret_sauce") self.lp.login_button_click() assert self.hp.burger_menu_exist() assert self.hp.shopping_cart_exist()
def test_addPost(self): home_page = HomePage(self.driver) sleep(3) home_page.click_on_post_settings() sleep(2) home_page.save_post() # home_page.click_on_post_settings() # home_page.is_post_saved()
def test_addPost(self): home_page = HomePage(self.driver) home_page.click_on_home_button() sleep(3) home_page.click_add_compose_post_button() home_page.add_post(self.VALUE) home_page.click_share_button() assert home_page.is_post_present(self.VALUE)
def click_on_accept_cookies_button(self): try: WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located( (By.ID, 'onetrust-accept-btn-handler'))) HomePage(self.driver).accept_cookies_button().click() except NoSuchElementException: return None
def check_products_appearing(self, letter): WebDriverWait(self.driver, 10).until(EC.url_contains, letter) WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located(( By.XPATH, '//div[contains(@class, ' '"GenericProduct__StyledProductLayout-sc-6ow56k-2 dRrPqt")]'))) data = HomePage(self.driver).select_first_record().is_displayed() return data
def test_assert_page_heading(self): home_page = HomePage() home_page.click_on_sign_in_link() authentication_page = AuthenticationPage() authentication_page.click_on_create_an_account_button() assert "Invalid email address." in self.driver.page_source()
def test_search_item_valid(self): search_term = "Dress" # Ideally to compare with DB search_results_counter = "7 results have been found." home_page = HomePage() home_page.enter_search_term(search_term) home_page.click_on_search_button() search_results_page = SearchResultsPage() if self.assertEqual(search_results_page.assert_search_term(), search_results_counter): pass else: self.driver.save_screenshot('ScreenShots/search_results_page.png')
class TestShopping: lp = LoginPage() hp = HomePage() blp = BikeLightPage() cp = CheckoutPages() def testAddToCart(self): self.hp.add_to_cart_from_home_page(1) self.hp.add_to_cart_from_home_page(3) self.hp.add_to_cart_from_home_page(5) self.hp.open_item() self.blp.add_to_cart_from_item() self.blp.back_to_home_page() assert self.hp.burger_menu_exist() assert self.hp.session_storage_is_full() def testRemoveFromCart(self): driver.execute_script( 'window.sessionStorage.setItem("cart-contents","[4,0,1]")') self.hp.remove_from_cart_home_page(1) self.hp.remove_from_cart_home_page(3) self.hp.open_item() self.blp.remove_from_cart_item() self.blp.back_to_home_page() assert self.hp.burger_menu_exist() assert self.hp.shopping_cart_num_exist() def testCheckout(self): driver.execute_script( 'window.sessionStorage.setItem("cart-contents","[4,0,1]")') self.hp.open_cart() self.cp.checkout_button_click() self.cp.fill_out_first_name() self.cp.fill_out_last_name() self.cp.fill_out_postal_code() self.cp.continue_button_click() self.cp.finish_button_click() assert self.cp.check_success_message() assert self.cp.check_success_url() assert self.hp.shopping_cart_num_exist()
def test_if_search_results_are_correct(self, init_driver): home_page = HomePage(init_driver) search_page = home_page.search_items(self.SEARCH_ITEM) assert search_page.are_search_results_correct(self.SEARCH_ITEM), "Search results are incorrect"
def test_if_site_url_is_correct(self, init_driver): home_page = HomePage(init_driver) actual_url = home_page.get_page_url() assert actual_url == self.APP_URL, "App URL is incorrect"
def classSetup(self, setUp): self.hp = HomePage(self.driver)
def test_add_item_to_compare(self, init_driver): home_page = HomePage(init_driver) search_page = home_page.search_items(self.SEARCH_ITEM) search_page.add_item_to_compare() assert search_page.is_added_to_compare_notification_displayed(), "Item was not added to comparison"
def test_if_site_title_is_correct(self, init_driver): home_page = HomePage(init_driver) actual_title = home_page.get_home_page_title() assert actual_title == self.APP_TITLE, "App title is incorrect"
def test_valid_login(self, browser): login_pg = LoginPage(browser) home_pg = HomePage(browser) browser.get("https://www.goodreads.com/") login_pg.with_(correct_username, correct_password) home_pg.success_message_present()
def click_on_wishlist_link(self): HomePage(self.driver).wishlist_link().click()
def click_on_home_button(self): home_button = self.driver.find_element(*self.HOME_LINK).click() return HomePage(self.driver)
def __init__(self, driver: webdriver): self.driver = driver self.home = HomePage(driver) self.registration = RegistrationPage(driver)
def enter_value_on_search_field(self, value): HomePage(self.driver).search_field().click() HomePage(self.driver).search_field().send_keys(value) HomePage(self.driver).search_field().send_keys(Keys.ENTER)
def select_wishlist_button(self): HomePage(self.driver).select_heart_button().click()
from selenium import webdriver from Pages.login_page import LoginPage from Pages.home_page import HomePage driver = webdriver.Chrome() driver.implicitly_wait(30) driver.maximize_window() driver.get("http://demo.actitime.com") login = LoginPage(driver) login.set_username("admin") login.set_password("manager") login.click_login_button() home = HomePage(driver) home.click_on_logout_link() driver.quit()