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 cpruploadwithoutpincode(self): time.sleep(3) driver.find_element_by_id("loenPeriodeStartDato").send_keys( "2020.09.01") time.sleep(3) driver.find_element_by_id("loenPeriodeSlutDato").send_keys( "2020.09.30") time.sleep(3) driver.find_element_by_id("dispositionsdato").send_keys("2020.09.15") time.sleep(3) 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[15]/td[2]/input" ).click() # Enter value in Fields time.sleep(3) # **************** Field 13 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[15]/td[2]/input" ).clear() 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[15]/td[2]/input" ).send_keys("1000") # **************** Field 14 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[15]/td[4]/input" ).clear() 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[15]/td[4]/input" ).send_keys("5000") driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td[2]/input" ).click() time.sleep(3)
def test_accept_cookie(self): driver.find_element_by_id("onetrust-accept-btn-handler").click() time.sleep(1)
# -*- coding: utf-8 -*- import requests as rq import driver from bs4 import BeautifulSoup as BS from selenium import webdriver import time pov = int(input("установите повторения: ")) pov_plus = 0 driver = webdriver.Chrome( "C:/Users/ludol/Desktop/stepan/chrome_driver/chromedriver") driver.get("https://www.b17.ru") while pov_plus < pov: try: driver.find_element_by_id("index_list_next").click() except (BaseException): pass last_height = driver.execute_script("return document.body.scrollHeight") driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") time.sleep(1.5) new_height = driver.execute_script("return document.body.scrollHeight") last_height = new_height pov_plus += 1 print("парсинг закончен, страница сохраняется") html_source = driver.page_source def obrabotka(obr): OnOff = False output = [] for i in range(len(obr)):
for sub in subs: print(sub.text) i = i + 10 import requests import driver driver.get("https://twitter.com/login") url = "https://twitter.com/login" element = driver.find_element_by_id("session[username_or_email]") payload = { 'session[username_or_email]': '*****@*****.**', 'session[password]': 'dlwnsgk94!'} r = requests.post(url, data=payload) r = requests.post("https://www.naver.com/") res = requests.get('https://twitter.com/Bo1210Cap/following') res = requests.get('https://www.naver.com/') soup = BeautifulSoup(res.content,'html.parser') followings = soup.find_all('span',{'class' : 'u-linkComplex-target'})
import time from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver import Chrome from selenium.webdriver.common.keys import Keys driver = Chrome() with Chrome() as driver: driver.get("http://automationpractice.com/index.php") driver.maximize_window() url = driver.current_url title = driver.title print(title) print(url) #assert 'The Internet' in driver.title departments = driver.find_element_by_id("block_top_menu") #time.sleep(10) women_department = driver.find_element_by_class_name("sf-with-ul").click() time.sleep(3) ActionChains(driver).move_to_element( driver.find_element_by_xpath( "//*[@id='center_column']/ul/li[6]")).perform() time.sleep(3) previous_dress_name = driver.find_element_by_xpath( "//*[@id='center_column']/ul/li[6]/div/div[2]/h5/a").text print(previous_dress_name) previous_dress_price = driver.find_element_by_xpath( "//*[@id='center_column']/ul/li[6]/div/div[1]/div/div[2]/span").text print(previous_dress_price) ActionChains(driver).move_to_element( driver.find_element_by_xpath(
def findById(self, driver, id): print("元素通过 ID 定位") return driver.find_element_by_id(id)
from pages.reimbursment_home import Reimbursment # WebElement = driver.find_element_by_id("q") driver: WebDriver = webdriver.Chrome( "/Users/alexjones/Desktop/RevatureTraining/chromedriver") main_page = Reimbursment(driver) try: # Login User That Created Request driver.get("file:///Users/alexjones/Desktop/RevatureTraining/reimbursment-client/home.html?") sleep(1) main_page.login_name_field().send_keys("5") sleep(2) main_page.login_name_button().send_keys(Keys.ENTER) sleep(2) nameo = driver.find_element_by_id("name") nameo = nameo.text assert nameo == "Giorno Giovanna" # Get Request Data main_page.request_name_field().send_keys("5") main_page.request_id_field().send_keys("1") sleep(1) main_page.view_request().send_keys(Keys.ENTER) sleep(3) nameo = driver.find_element_by_id("req_name") nameo = nameo.text assert nameo == "Giorno Giovanna" # Check Buttons dont work main_page.denial_reason_field().send_keys("5")
def createdynamicrule(self): # Click New Rule Button driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr/td/input" ).click() time.sleep(5) # Pass entire file path as parameter file_path = ( r"C:\Users\AbhinavDixit\PycharmProjects\Skat-eIncomes\Online-INDB\Dynamic_Validation_Rule\Dynamic_Rule_creation.xlsx" ) # set file path book = xlrd.open_workbook(file_path) sh = book.sheet_by_index(0) # Enter value in Fejlnr Field Fejlnr = sh.cell_value(rowx=1, colx=0) print("Fejlnr:-", Fejlnr) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/input" ).send_keys(Fejlnr) # Enter value in Fejltekst Field Fejltekst = sh.cell_value(rowx=1, colx=1) print("Fejltekst:-", Fejltekst) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table[1]/tbody/tr[1]/td[4]/textarea" ).send_keys(Fejltekst) # Enter value in Fejlbeskrivelse Field Fejlbeskrivelse = sh.cell_value(rowx=1, colx=2) print("Fejlbeskrivelse :-", Fejlbeskrivelse) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table[1]/tbody/tr[2]/td[4]/textarea" ).send_keys(Fejlbeskrivelse) # Enter value in Gældende fra Field Valid_from = sh.cell_value(rowx=1, colx=3) print("Valid_from :-", Valid_from) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr[1]/td[1]/input" ).send_keys(Valid_from) # Enter value in Gældende til Field Valid_Till = sh.cell_value(rowx=1, colx=4) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr[1]/td[2]/input" ).send_keys(Valid_Till) # ******************************** CONDITION ********************************************************** # Select Radio Button for condition driver.find_element_by_xpath("//*[@id='betingelse_6001']").click() time.sleep(3) # Enter value of Vælg betingelse # Select Condition Value from Excel conditon = int(sh.cell_value(rowx=1, colx=5)) print("condition value", conditon) a = PythonSwitch() a.switch(conditon) print("CONDITON VALUE IS", a.switch(conditon)) driver.find_element_by_xpath(a.switch(conditon)).click() # Select Operator from Excel Operator = sh.cell_value(rowx=1, colx=6) print("Operator value", Operator) driver.find_element_by_xpath(Operator).click() # driver.find_element_by_css_selector("table.clContentTable:nth-child(4) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(2) > select:nth-child(1)"). \ send_keys(conditon) time.sleep(2) # Enter value of Condition Condition_Value = int(sh.cell_value(rowx=1, colx=7)) print("Operator value", Condition_Value) driver.find_element_by_name("betingelse_veardi").send_keys( Condition_Value) time.sleep(3) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table[4]/tbody/tr[5]/td/input[2]" ).click() time.sleep(3) driver.find_element_by_id("betingelse_5000_6000").click() time.sleep(2) # ******************************** RULE ********************************************************** # Select Radio Button for Rule(Vælg regel) driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") driver.find_element_by_id("regel_6001").click() time.sleep(3) # Enter value of Vælg regel # #Select Rule Value from Excel Rule = int(sh.cell_value(rowx=1, colx=8)) print("Rule value", Rule) a = PythonSwitch() a.switch(Rule) print("RULE VALUE IS", a.switch(Rule)) time.sleep(2) driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") time.sleep(2) # driver.find_element_by_xpath("/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table[6]/tbody/tr[3]/td[1]/select/option[1]").click() driver.find_element_by_name( "regel_record_selected").find_element_by_xpath( a.switch(Rule)).click() # driver.find_element_by_xpath("//option[@value='6001.66']").click() # Select Operator from Excel Operator = sh.cell_value(rowx=1, colx=6) print("Operator value", Operator) driver.find_element_by_xpath(Operator).click() # driver.find_element_by_css_selector("table.clContentTable:nth-child(4) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(2) > select:nth-child(1)"). \ send_keys(conditon) time.sleep(2) # Enter value of Rule Rule_Value = int(sh.cell_value(rowx=1, colx=9)) print("Operator value", Rule_Value) driver.find_element_by_name("regel_veardi").send_keys(Rule_Value) time.sleep(3) driver.find_element_by_xpath( "/html/body/table[2]/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr/td/table[6]/tbody/tr[5]/td/input[2]" ).click() time.sleep(3)
import driver as driver from selenium import webdriver from selenium.webdriver.common.keys import Keys import random import time from selenium.webdriver.remote.webelement import WebElement driver = webdriver.Chrome() driver.get("http://172.16.6.108/user/login") driver.maximize_window() driver.find_element_by_id("login-form_username").send_keys("admin") driver.find_element_by_id("login-form_password").send_keys("yjg123456") driver.find_element_by_xpath("//button[@type='submit']").click() time.sleep(5) driver.find_element_by_xpath("//span[text()='权限管理']/..").click() time.sleep(5) driver.find_element_by_xpath("//span[text()='用户管理']/../..").click() time.sleep(5) driver.find_element_by_xpath("//div[@class='ant-card ant-card-middle']//button[@class='ant-btn ant-btn-primary']").click() time.sleep(5) usernameNO = str(random.randint(0,10000)) loginnameNO = str(random.randint(0,10000)) phoneNO = str(random.randint(9999999,100000000)) username = "******" + usernameNO loginname = "NovaAuto" + loginnameNO phonenumer = "187" + phoneNO driver.find_element_by_id("userName").send_keys(username) time.sleep(1) driver.find_element_by_xpath("//input[@placeholder='请输入手机号码']").send_keys(phonenumer) time.sleep(1)