def open_links(): driver.get(robots) driver.execute_script("window.open('');") driver.switch_to.window(driver.window_handles[1]) driver.get(sitemap) driver.execute_script("window.open('');") driver.switch_to.window(driver.window_handles[2]) driver.get(url)
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 xh(self): t = True time.sleep(1) while t: driver.execute_script("window.scrollBy(0,1000)") try: driver.find_element('link_text', '没有更多推荐了,返回首页').click() time.sleep(1) t = False except: self.xh()
def page_scroller(driver, range_value): for i in range(0, range_value): driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") time.sleep(3)
def test_scroll_blog(self): driver.execute_script("window.scrollTo(0,500)") time.sleep(1) driver.execute_script("window.scrollTo(0,900)") time.sleep(1) driver.execute_script("window.scrollTo(0,1400)") time.sleep(1) driver.execute_script("window.scrollTo(0,1900)") time.sleep(1) driver.execute_script("window.scrollTo(0,2200)") time.sleep(1) page = driver.find_element_by_tag_name("html") page.send_keys(Keys.END) time.sleep(2) driver.execute_script("window.scrollTo(0,50)") time.sleep(1)
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)): list_names = list(obr[i]) for j in range(len(list_names)):
def script(self, driver, src): return driver.execute_script(src)
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)
if url_match_regex.match(str(href)): url_not_match_regex = re.compile('(?!.*google.*)') if url_not_match_regex.match(str(href)): store.append(href) print(href) return store store_url = list(search_store()) # var_regex = r"\b(?=\w)" + re.escape(TEXTO) + r"\b(?!\w)" store_url_index = input( "Please type the store URL index; index starts from 0 and numbered only:") store_url_index = int(store_url_index) print("The selected store URL is: " + store_url[store_url_index]) ''' driver.execute_script("window.open('');") driver.switch_to.window(driver.window_handles[3]) driver.get(store_url[store_url_index]) ''' driver = webdriver.Firefox() driver.get(store_url[store_url_index]) def respo(): print("Current Browser URL is: " + driver.current_url) try: api_calls = [] for requ in driver.requests: res = requ.response.headers['Content-Type']