def test_search_valid_category(self): driver = self.driver search_product = SearchproductTest(driver) WebActions.wait(self, 10) search_product.shopByCateogry() search_product.select_sofas_as_furniture_cateogry() search_product.select_sofas_by_type()
def Gotologinpage(self): try: element = self.driver.find_element_by_id(Locators.SignIn_Button_id) WebActions.click_on_element(self, element) Log.write_info_to_log_file(self, "Login successfully") except: print("")
def select_sofas_by_type(self): try: sofas_type = self.driver.find_element_by_xpath(Locators.select_sofa_type_by_xpath) WebActions.click_on_element(self, sofas_type) Log.write_info_to_log_file(self,"sofa type selected successfully") except: Log.write_errors_to_log_file(self,"sofas type not selected")
def select_sofas_as_furniture_cateogry(self): try: element = self.driver.find_element_by_xpath(Locators.select_sofas_as_furniture_category_by_xpath) WebActions.click_on_element(self, element) Log.write_info_to_log_file(self,"sofas as furniture category selected") except TimeoutException: Log.write_errors_to_log_file(self,"selection of furniture category failed")
def test_valid_logout(self): driver = self.driver WebActions.wait(self, 10) homepage = HomePage(driver) homepage.checkOrders() homepage.navigatebacktoHomepage() WebActions.wait(self, 10) homepage.signoutfrompage()
def enterusername(self, username): try: element = self.driver.find_element_by_id( Locators.Username_TextBox_id) WebActions.send_value_to_textbox(self, username, element) Log.write_info_to_log_file(self, "User name entered successfully") except: Log.write_errors_to_log_file(self, "Entering username failed")
def clickonloginbutton(self): try: element = self.driver.find_element_by_id(Locators.Login_button_id) WebActions.click_on_element(self, element) Log.write_info_to_log_file(self, "clicked on login button successfully") except: Log.write_errors_to_log_file(self, "clicked on login button failed")
def enterpassword(self, password): try: element = self.driver.find_element_by_id( Locators.Password_TextBox_id) WebActions.send_value_to_textbox(self, password, element) Log.write_info_to_log_file(self, "Password value entered successfully") except: Log.write_errors_to_log_file(self, "Entering password failed")
def navigatebacktoHomepage(self): try: element = self.driver.find_element_by_class_name( Locators.Nav_home_page_class_name) WebActions.click_on_element(self, element) Log.write_info_to_log_file(self, "Navigate to Home Page successfully") except: Log.write_errors_to_log_file( self, "Navigation to Home Page is not successfully")
def checkOrders(self): try: element = self.driver.find_element_by_id( Locators.Nav_order_page_class_name) WebActions.click_on_element(self, element) Log.write_info_to_log_file(self, "Element is clicked on successfully") except: Log.write_errors_to_log_file( self, "Element is not clicked successfully")
def clickfornextloginpage(self): try: element = self.driver.find_element_by_id( Locators.Continue_Button_id) WebActions.click_on_element(self, element) Log.write_info_to_log_file( self, "Navigate to next Login page successfully") except: Log.write_errors_to_log_file(self, "Click on next login button Failed")
def signoutfrompage(self): try: action = ActionChains(self.driver) element = self.driver.find_element_by_id("nav-link-accountList") action.move_to_element(element).perform() myElem = Waits.wait_for_element_presence(self, By.XPATH, Locators.Logout_id) #myElem = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH, Locators.Logout_id))) WebActions.wait(self, 10) myElem.click() Log.write_info_to_log_file(self, "sign out from website successfully") except TimeoutException: Log.write_errors_to_log_file(self, "Sign out failed")
def select_category_from_dropdown(self): try: WebActions.select_element_from_dropdown_by_value( self, Locators.select_dropdown_option_id, "search-alias=mobile-apps") element = self.driver.find_element_by_id( Locators.search_text_box_id) WebActions.press_keyboard_enter_key(self, Keys.ENTER, element, "Mobile") Log.write_info_to_log_file(self, "category selected from drop down") except: Log.write_info_to_log_file(self, "select categroy from dropdown failed")
def shopByCateogry(self): driver = self.driver mouse_action = WebActions(self.driver) waits = Waits(driver) #WebActions.wait(self) self.driver.find_element_by_id("nav-link-shopall") WebActions.wait(self,10) element = waits.wait_for_element_presence(By.ID, "nav-link-shopall") mouse_action.hover_on_mouse_action(element) Log.write_info_to_log_file(self,"hover on all product list") try: element1 = self.driver.find_element_by_xpath(Locators.select_kitche_tool_category_label) WebActions.wait(self,10) mouse_action.hover_on_mouse_action(element1) Log.write_info_to_log_file(self,"hover on kitchen tool list") waits.wait_for_element_presence(By.XPATH, Locators.select_furniture_category_by_xpath).click() except TimeoutException: Log.write_errors_to_log_file(self,"Not able to navigate to furniture page")