def select_demo3(): driver.get("http://ui.yansl.com/#/select") select = driver.find_element_by_xpath("//input[@name='item4']") sleep(2) selecti = driver.find_element_by_xpath("(//li[@name='option4'])[2]") selecti.click() sleep(1)
def readINDBfromexcel(self): # Pass entire file path as parameter # set file path file_path = ( r"C:\Users\AbhinavDixit\PycharmProjects\Skat-eIncomes\Online-INDB\1-Submit_Online-INDB\Online_INDB_Excel.xlsx" ) book = xlrd.open_workbook(file_path) aa = book.sheet_by_index(0) list_ad = [] total_rows = aa.nrows print("Total number of Rows are:", total_rows) for i in range(1, total_rows): list_ad.append(aa.cell(rowx=i, colx=0).value) print("Length of List", len(list_ad)) print("LIST", list_ad) print("THE FINAL LIST IS ", list_ad) time.sleep(3) recent_indbid = list_ad[-1] # Enter INDB ID to be searched driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[7]/td[2]/input" ).send_keys(recent_indbid) driver.find_element_by_xpath( "//*[@id='defaultButton']").click() # Press Sog Button indbreversal.indbreversalmethod(self, recent_indbid)
def logic_credentials(self): #time.sleep(3) #driver.switch_to.frame("letloen") time.sleep(5) driver.find_element_by_css_selector('#defaultFocusElementId').send_keys("Admin1032") driver.find_element_by_name("password").send_keys("Test1234") driver.find_element_by_xpath("//*[@id='defaultButton']").click()
def test_continue_click(self): driver.find_element_by_xpath( "//*[@data-qa='header-navigation-item-company']").click() time.sleep(1) driver.find_element_by_xpath( "//*[@data-qa='header-navigation-item-career']").click() time.sleep(1)
def test_search(self): driver.find_element_by_xpath("//i[@class='icon-search']").click() time.sleep(1) driver.find_element_by_xpath( "//input[@ng-change='search.doSearch(search.searchTerm)']" ).send_keys("blog") time.sleep(1)
def is_present_vm(driver, vmName): time.sleep(10) # WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.XPATH,u'//*[@id="stretch-table"]/tbody/tr/td[1]/a[@vmName="%s]' % vmName))).click() all_row = driver.find_elements_by_xpath('//*[@name="dataTr"]') print(all_row) # def is_present_vm(driver,vmName): rownum = len(all_row) for i in range(rownum): print(all_row[i]) name = all_row[i].find_elements_by_tag_name('td')[1].text.split("-")[0] name1 = all_row[i].find_elements_by_tag_name('td')[1].text status = all_row[i].find_elements_by_tag_name('td')[2].text print("vmName is %s,vmStatus is %s" % (name, status)) if name == vmName: print("enter click vmname,i") print(i) # all_row[i].find_elements_by_xpath('td[1]/input')[.click() # # driver.find_element_by_xpath("//*[@id='stretch-table']/tbody/tr[%s]/td[3]" %i).click() # Select = driver.find_element_by_xpath("/*[@id='stretch-table']/tbody/tr/td[1]/input") driver.find_element_by_xpath( "//*[@id='stretch-table']/tbody/tr['%s']/td[1]/input" % i).click() # driver.find_element_by_xpath("//*[@id='stretch-table']/tbody/tr[1]/td[1]/input").send_keys(Keys.SPACE) # if driver.find_element_by_xpath('//input/../[@displayname="%s"]',% name1).is_selected(): if driver.find_element_by_xpath( "//*[@id='stretch-table']/tbody/tr['%s']/td[1]/input" % i).is_selected(): print('vm is selected!') else: print('vm not selected!') return status
def select_demo(): driver.get("http://ui.yansl.com/#/select") sleep(2) select = driver.find_element_by_xpath("//input[@name='item2']") select.click() sleep(1) lll = driver.find_element_by_xpath("//span[text() = '黄金糕2']") lll.click()
def cascader_demo(): driver.get("http://ui.yansl.com/#/cascader") sleep(2) driver.find_element_by_xpath("//label[text()='hover触发']/../div//input").click() sleep(2) zu_jian=driver.find_element_by_xpath("(//span[text()='组件'])[last()]") actions = ActionChains(driver) actions.move_to_element(zu_jian).perform()
def enterCPRSENR(self): # Enter CVR/SE-nr Number time.sleep(5) driver.switch_to.__class__("clContentTable") time.sleep(5) driver.find_element_by_class_name("inputButton").click() time.sleep(5) driver.find_element_by_id("defaultFocusElementId").send_keys("37172715") driver.find_element_by_xpath("//*[@id='defaultButton']").click()
def isElementExist(self, element): flag = True driver = self.driver try: driver.find_element_by_xpath(element) except: flag = False return flag
def selecteIndkomst(self): # Select EIncome Radio Button time.sleep(5) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[1]/td/table/tbody/tr/td/table/tbody/tr/td[1]/div/table/tbody/tr[4]/td[2]/span[2]/input" ).click() #driver.find_element_by_css_selector("body > table:nth-child(5) > tbody:nth-child(4) > tr:nth-child(1) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(1) > div:nth-child(2) > table:nth-child(2) > tbody:nth-child(1) > tr:nth-child(5) > td:nth-child(2) > span:nth-child(2) > input:nth-child(1)").click() time.sleep(5) test.entercpr(self) time.sleep(3)
def checkForDyRulePincode(self): try: driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[1]/td/table/tbody/tr/td/table/tbody/tr/td[1]/div/div/div/div[2]/input[1]" ).is_displayed() print("Dynamic Rule displayed") test.pincodedyvalidation(self) except NoSuchElementException: print("No Dynamic Rule displayed") test.copy_data_excel_method(self)
def dynamicScreenNavigation(self): driver.find_element_by_xpath( "/html/body/div[2]/span[1]/a").click() # Click Indkomst menu time.sleep(3) # Click Systemadministration menu test.handle_current_window_method(self) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td[1]/table/tbody/tr[1]/td/a[24]" ).click() test.handle_current_window_method(self) time.sleep(5)
def select_demo2(): driver.get("http://ui.yansl.com/#/select") sleep(2) select = driver.find_element_by_xpath("//input[@name='item3']") select.click() sleep(1) select2 = driver.find_element_by_xpath("(//span[text()='双皮奶'])[5]") select2.click() sleep(1) select2 = driver.find_element_by_xpath("//form") # 要点击空白的地方定位 select2.click()
def test_contact(self): driver.find_element_by_xpath( "//*[@data-qa='header-navigation-item-contact']").click() time.sleep(2) page = driver.find_element_by_tag_name("html") page.send_keys(Keys.END) time.sleep(1) driver.execute_script("window.scrollTo(0,400)") time.sleep(1) driver.execute_script("window.scrollTo(0,50)") time.sleep(1)
def restart_vm(driver, vmName): # vmStatus=is_present_vm(driver,vmName) result = select_vm(driver, vmName) vmStatus = result[1] if vmStatus == u'运行': driver.find_element_by_xpath('//*[@id="operations"]/a[1]').click() WebDriverWait(driver, 40).until( EC.element_to_be_clickable( (By.XPATH, u"html/body/div[5]/div[3]/div/button[1]"))).click() time.sleep(20) vmStatus2 = is_present_vm(driver, vmName) if vmStatus2 == u'运行': print("start vm sucess")
def copy_to_templet(driver, vmName): # result=select_vm(driver,vmName) isstop_vm(driver, vmName) # vmName2=result[0] templa_name = templaname_gen() driver.find_element_by_xpath( "//*[@id='operations']/a/span[contains(text(),'复制为模板')]").click() # WebDriverWait(driver, 20).until( # EC.element_to_be_clickable((By.XPATH, u"//*[@id='copy_as_template_form']/div/div/input[@name='name']"))).send_ke # driver.find_element_by_xpath(u"//*[@id='copy_as_template_form']/div/div/input[@name='name']").clear() driver.find_element_by_xpath( u"//*[@id='copy_as_template_form']/div/div/input[@name='name']" ).send_keys(templa_name) driver.find_element_by_xpath( u"//*[@id='copy_as_template_form']/div/div/textarea").send_keys( templa_name) driver.find_element_by_xpath(u"//*[@id='submit_but']").click() info = WebDriverWait(driver, 20).until( EC.visibility_of_element_located( (By.XPATH, u"//*[@id='infoMessage']"))).text WebDriverWait(driver, 20).until( EC.element_to_be_clickable( (By.XPATH, u"html/body//div[contains(@style,'display: block;')]/div/button" ))).click() if info.__contains__("复制为模板任务启动成功!"): print("复制为模板任务启动成功") else: print("复制为模板任务启动failed")
def dynamicscreennavigation(self): time.sleep(4) # click on Systemadministration link driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td[1]/table/tbody/tr[1]/td/a[24]" ).click() dynamicruleclass.handle_current_window_method(self) time.sleep(5) # Click on Dynamiske valideringsregler link driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[2]/td/a[13]" ).click() dynamicruleclass.handle_current_window_method(self) time.sleep(3) dynamicruleclass.createdynamicrule(self)
def entercpr(self): time.sleep(2) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[1]/td/table/tbody/tr/td/table/tbody/tr/td[1]/div/table/tbody/tr[8]/td[2]/input" ).send_keys("1909580060") time.sleep(2) # driver.find_element_by_xpath("/html/body/table[2]/tbody/tr[1]/td/table/tbody/tr/td/table/tbody/tr/td[1]/div/table/tbody/tr[8]/td[2]/input").send_keys("1909580060") #Provide CPR-no driver.find_element_by_xpath("//*[@id='defaultButton']").click() time.sleep(3) Title = driver.title print("Title of new page is", Title) if Title == "SKAT, eIndkomst, Personstamoplysninger": test.Personstamoplysninger(self) else: test.cpruploadwithpincode(self)
def Personstamoplysninger(self): time.sleep(2) driver.find_element_by_name( 'ansaettelsesOplysningerForm.ansaettelsesDato').send_keys(20200401) driver.find_element_by_name( 'ansaettelsesOplysningerForm.fratraedelsesDato').send_keys( 20200401) driver.find_element_by_name( 'ansaettelsesOplysningerForm.skattekortTypeAnvendFra').send_keys( 20200401) driver.find_element_by_name( 'ansaettelsesOplysningerForm.supplerendeMedarbejderNr').send_keys( 20200401) driver.find_element_by_xpath("//*[@id='defaultButton']").click() time.sleep(3)
def test_hover(self): element = driver.find_element_by_link_text("Solutions") hover = ActionChains(driver).move_to_element(element) hover.perform() time.sleep(1) element = driver.find_element_by_link_text("Products") hover = ActionChains(driver).move_to_element(element) hover.perform() time.sleep(1) element = driver.find_element_by_link_text("Clients") hover = ActionChains(driver).move_to_element(element) hover.perform() time.sleep(1) element = driver.find_element_by_link_text("Company") hover = ActionChains(driver).move_to_element(element) hover.perform() time.sleep(1) element = driver.find_element_by_link_text("Blog") hover = ActionChains(driver).move_to_element(element) hover.perform() time.sleep(1) element = driver.find_element_by_link_text("Careers") hover = ActionChains(driver).move_to_element(element) hover.perform() time.sleep(1) element = driver.find_element_by_link_text("Contact") hover = ActionChains(driver).move_to_element(element) hover.perform() time.sleep(1) element = driver.find_element_by_xpath("//i[@class='icon-search']") hover = ActionChains(driver).move_to_element(element) hover.perform() time.sleep(1)
def delete_vm(driver, vmName): # result = select_vm(driver, vmName) # vmName = result[0] driver.find_element_by_xpath("//*[@id='operations']/a[5]/span").click() WebDriverWait(driver, 40).until( EC.element_to_be_clickable( (By.XPATH, u"html/body/div[5]/div[3]/div/button[1]"))).click() try: WebDriverWait(driver, 40).until( EC.invisibility_of_element_located(( By.XPATH, "//*[@id='stretch-table']/tbody/tr[@displayname='%s']/td[1]/input" % vmName))) print("delete vmname '%s' success", vmName) except TimeoutException: print("delete vmname '%s' failed", vmName)
def check_box_demo4(): driver.get("http://ui.yansl.com/#/checkbox") sleep(2) check_box = driver.find_element_by_xpath("//span[text()='上海']/../span/span") check_box.click() if (not check_box.is_selected()) : # 判断条件 check_box.click()
def check_box_demo2(): driver.get("http://ui.yansl.com/#/checkbox") sleep(2) check_box = driver.find_element_by_xpath("//span[@class='el-checkbox__inner']") check_box.click() if (not check_box.is_selected()):# 判断条件 check_box.click()
def check_box_demo(): driver.get("http://ui.yansl.com/#/checkbox") sleep(2) check_box = driver.find_element_by_xpath("//input[@value='1']") check_box.click() if (not check_box.is_selected()): check_box.click()
def copy_data_excel_method(self): # ************** Load Excel **************# path = ( r"C:\Users\AbhinavDixit\PycharmProjects\Skat-eIncomes\Online-INDB\1-Submit_Online-INDB\Online_INDB_Excel.xlsx" ) workbook = openpyxl.load_workbook(path) # Load Workbook sheet = workbook['INDBID'] time.sleep(5) INDB_ID = driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[1]/td/table/tbody/tr/td/table/tbody/tr/td[1]/div/table[2]/tbody/tr[3]/td[2]" ).text print(INDB_ID) # Copy INDB_ID in to Excel i = 2 while sheet.cell(row=i, column=1).value != None: i = i + 1 sheet.cell(i, 1).value = INDB_ID workbook.save(path) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td[2]/input" ).click()
def restart_vm(driver, vmName): # vmStatus=is_present_vm(driver,vmName) # result = select_vm(driver, vmName) # vmStatus = result[1] status = driver.find_element_by_xpath( "//*[@id='stretch-table']/tbody/tr[@displayname='%s']/td[3]" % vmName).text if status == '运行': print("start to restart vm") driver.find_element_by_xpath('//*[@id="operations"]/a[3]').click() time.sleep(2) driver.find_element_by_xpath(OK_BUTTON).click() time.sleep(35) WebDriverWait(driver, 30).until( EC.element_to_be_clickable(( By.XPATH, u'//*[@id="mCSB_1_container"]/ul[1]/li/a/span[contains(text(),"虚拟机管理")]' ))).click() time.sleep(10) vmstatus = driver.find_element_by_xpath( "//*[@id='stretch-table']/tbody/tr[@displayname='%s']/td[3]" % vmName).text if vmstatus == u'运行': print("restart vm sucess")
def select_vm(driver, vmName): # number=vmName.split('-')[1] vmName2 = vmName + '-1' print("vmName with number", vmName2) time.sleep(10) WebDriverWait(driver, 30).until( EC.element_to_be_clickable( (By.XPATH, "//*[@id='stretch-table']/tbody/tr[@displayname='%s']/td[1]/input" % vmName2))).click() if driver.find_element_by_xpath( "//*[@id='stretch-table']/tbody/tr[@displayname='%s']/td[1]/input" % vmName2).is_selected(): print('vm is selected!') else: print('vm not selected!') status = driver.find_element_by_xpath( "//*[@id='stretch-table']/tbody/tr[@displayname='%s']/td[3]" % vmName2).text print("status", status) return vmName2, status
def vnc_view(driver, vmName): isstart_vm(driver, vmName) vmName2 = vmName + '-1' vnclink = driver.find_element_by_xpath( "//*[@id='stretch-table']/tbody/tr[@displayname='%s']/td[10]/a[contains(text(),'VNC访问')]" % vmName2) url = vnclink.get_attribute('href') print(url) r = requests.get(url, allow_redirects=False) print(r.status_code) if r.status_code == 200: print("vnc 访问成功") else: print("vnc 访问失败")
def test_swipe_client(self): driver.find_element_by_xpath( "//div[@class='swiper-button-next']").click() time.sleep(1) driver.find_element_by_xpath( "//div[@class='swiper-button-next']").click() time.sleep(1) driver.find_element_by_xpath( "//div[@class='swiper-button-next']").click() time.sleep(1)