class MainNavigation(object): def __init__(self, driver): self.driver = driver self.driver_waits = DriverWaits(self.driver) def go_to_all_courses_page(self): self.driver.find_element(*MainNavLocators.ALL_COURSES_LINK).click() self.driver_waits.wait_till_element_is_visible( CoursesPageLocators.COURSE_DIRECTORY) time.sleep(5) def go_to_home(self): self.driver.find_element(*MainNavLocators.BRAND_LOGO).click() self.driver_waits.wait_till_element_is_visible( HomePageLocators.COURSE_LIST_BLOCK) def logout(self): self.driver.find_element(*MainNavLocators.MY_PROFILE_ICON).click() self.driver_waits.wait_till_element_is_clickable( MainNavLocators.LOGOUT_LINK) time.sleep(1) self.driver.find_element(*MainNavLocators.LOGOUT_LINK).click() self.driver_waits.wait_till_element_is_visible( MainNavLocators.LOGIN_LINK)
class LoginPage(object): def __init__(self, driver): self.driver = driver self.driver_waits = DriverWaits(self.driver) def login(self, credentials=settings.LOGIN_CREDENTIALS): self.driver.find_element(*MainNavLocators.LOGIN_LINK).click() self.driver_waits.wait_till_element_is_visible( LoginPageLocators.LOGIN_BUTTON) email_input = self.driver.find_element(*LoginPageLocators.EMAIL_INPUT) email_input.clear() email_input.send_keys(credentials['email']) password_input = self.driver.find_element( *LoginPageLocators.PASSWORD_INPUT) password_input.clear() password_input.send_keys(credentials['password']) self.driver_waits.wait_till_element_is_clickable( LoginPageLocators.LOGIN_BUTTON) self.driver.find_element(*LoginPageLocators.LOGIN_BUTTON).click() self.driver_waits.wait_till_element_is_visible( MainNavLocators.MY_PROFILE_ICON)
class MainNavigation(object): def __init__(self, driver): self.driver = driver self.driver_waits = DriverWaits(self.driver) def logout(self): self.driver.find_element(*MainNavLocators.MY_PROFILE_ICON).click() self.driver_waits.wait_till_element_is_clickable(MainNavLocators.LOGOUT_LINK) time.sleep(1) self.driver.find_element(*MainNavLocators.LOGOUT_LINK).click() self.driver_waits.wait_till_element_is_visible(MainNavLocators.LOGIN_LINK)