def test_WindowsTest(self): self.elementmethods = ElementMethods(self.driver) self.pagemethods = PageMethods(self.driver) self.switchtomenu = self.driver.find_element_by_xpath( "//a[contains(text(),'Switch')]") self.elementmethods.HowerElement(self.switchtomenu) self.alerts = self.driver.find_element_by_xpath( "//a[contains(text(),'Windows')]") self.alerts.click() self.pagemethods.processWindows(0) print(self.driver.title) self.pagemethods.ValidateTitlePage("Frames & windows") # ma mut cu actiunea pe noul tab self.pagemethods.switchBetweenWindows() self.pagemethods.processWindows(1) self.pagemethods.switchBetweenWindows() self.pagemethods.processWindows(2) time.sleep(5)
def test_Alert(self): # se face o metoda de test self.element_methods = ElementMethods(self.driver) self.page_methods = PageMethods(self.driver) self.page_methods.ValidateTitlePage("Register") # Facem hower pe un element self.switch_to_menu = self.driver.find_element_by_xpath("//a[contains(text(),'Switch')]") self.element_methods.HowerElement(self.switch_to_menu) self.alerts = self.driver.find_element_by_xpath("//a[contains(text(),'Alerts')]") self.element_methods.ClickElement(self.alerts) # selectam primul element din lista self.element_methods.clickListElement("//ul[@class='nav nav-tabs nav-stacked']/li/a") self.element_methods.clickListElement("//button[contains(text(),'click the button')]") # interactionam cu alerte self.element_methods.interactionWithAlerts() alerts_list_path = "//ul[@class='nav nav-tabs nav-stacked']/li/a" buttons_list_path= "//button[contains(text(),'click the button')]" self.element_methods.clickListElement(alerts_list_path, 1) self.element_methods.clickListElement(buttons_list_path, 1) # self.alertslist[1].click() # self.buttons[1].click() self.element_methods.interactionWithAlerts(False) # trebuie sa declar mesajul care apare pe pagina # iau textul de pe mesaj/element self.element_methods.clickListElement(alerts_list_path, 2) self.element_methods.clickListElement(buttons_list_path, 2) # self.alertslist[2].click() # self.buttons[2].click() # # self.alert3 = WebDriverWait(self.driver, 10).until(EC.alert_is_present()) # print(self.alert3.text) # self.alert3.send_keys("Ceva scris aici") # self.alert3.accept() time.sleep(5)
def test_Register(self): # se face o metoda de test # declaram un obiect de tipul elementmethod pentru a folosi metodele generale self.elementmethods = ElementMethods(self.driver) self.pagemethods = PageMethods(self.driver) #declaram un obiect de tipul excel de la o anumita locatie si cu un sheet specific self.excelUtility = ExcelUtility("../Libre/DataDrivenTesting.xlsx", "ForRegister") # validam pagina pe care ne aflam # completam fieldul de first name si last name (radiobox) self.registerPage = RegisterPage(self.driver) self.registerPage.registerProcess( self.excelUtility.readDataByIndex(2, 2), "Buna") #dupa ce am terminat de declarat elementele+elementul submit #self.registerPage.clickSubmit() self.addressweb = self.driver.find_element_by_xpath("//textarea") self.elementmethods.WriteElement(self.addressweb, "sjhasgd") self.emailaddressweb = self.driver.find_element_by_xpath( "//input[@ng-model='EmailAdress']") self.elementmethods.WriteElement( self.emailaddressweb, self.excelUtility.readDataByIndex(4, 2)) self.phonenumberweb = self.driver.find_element_by_xpath( "//input[@type='tel']") self.elementmethods.WriteElement(self.phonenumberweb, "3475322958") # selectam un gen (checkbox) # selectam un hobby self.cricket = self.driver.find_element_by_xpath( "//input[@value='Cricket']") self.elementmethods.ClickElement(self.cricket) # alegem valoarea dintr-un dropdown self.countryweb = self.driver.find_element_by_id("countries") self.elementmethods.SelectElementByText(self.countryweb, "Romania") self.yearweb = self.driver.find_element_by_id("yearbox") self.elementmethods.SelectElementByValue(self.yearweb, "1994") self.monthweb = self.driver.find_element_by_xpath( "//select[@placeholder='Month']") self.elementmethods.SelectElementByText(self.monthweb, "August") self.dayweb = self.driver.find_element_by_xpath( "//select[@placeholder='Day']") self.elementmethods.SelectElementByValue(self.dayweb, "2") self.passwordweb = self.driver.find_element_by_id("firstpassword") self.elementmethods.WriteElement(self.passwordweb, "Qwerty1") self.confirmpasswordweb = self.driver.find_element_by_id( "secondpassword") self.elementmethods.WriteElement(self.confirmpasswordweb, "Qwerty1") self.submitweb = self.driver.find_element_by_id("submitbtn") self.elementmethods.ClickElement(self.submitweb) self.driver.find_element_by_xpath("//body[@ng-controller='gridctrl']") self.expectednextpage = "Web Table" self.pagemethods.ValidateTitlePage(self.expectednextpage) time.sleep(5)
def __init__(self, driver): self.driver = driver self.elementMethods = ElementMethods(self.driver) self.pageMethods = PageMethods(self.driver)