Section 25 positioned element selenium

 1 from selenium import webdriver
 2 from selenium.webdriver.chrome.options import Options
 3 from selenium.webdriver.common.by import By
 4 
 5 
 6 browers_path = r'C:\Users\Administrator\AppData\Local\360Chrome\Chrome\Application\360chrome.exe'
 7 chrome_option = Options()
 8 chrome_option.binary_location = browers_path
 9 browers_driver = webdriver.Chrome(options=chrome_option)
10 browers_driver.get("http://www.baidu.com")
11 # inputag = browers_driver.find_element_by_id('kw')
12 # inputag = browers_driver.find_element_by_name('wd')
13 # inputag = browers_driver.find_element_by_class_name('s_ipt')
14 inputag = browers_driver.find_element_by_xpath('//input[@id="kw"]')
15 inputag2 = browers_driver.find_element(By.XPATH, '//input[@id="kw"]')#简写方式
16 inputag.send_keys('python')

 

Guess you like

Origin www.cnblogs.com/kogmaw/p/12507099.html