Section twenty sixth form element selenium operations

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time


browers_path = r'C:\Users\Administrator\AppData\Local\360Chrome\Chrome\Application\360chrome.exe'
chrome_option = Options()
chrome_option.binary_location = browers_path
browers_driver = webdriver.Chrome(options=chrome_option)
'''
百度搜索输入关键词,点击搜索,在清除关键词
'''
# from selenium.webdriver.support.ui import Select
# browers_driver.get("http://www.baidu.com")
# Inputag = browers_driver.find_element_by_id ( 'kW') 
# inputag.send_keys ( 'Python') 
# the time.sleep (2) 
# submitag = browers_driver.find_element_by_id ( 'SU') 
# submitag.click () 
# the time.sleep (2 ) 
# inputag.clear () 
'' ' 
watercress click to select the next automatically log 
frame framework issues, in order to select the first frame into the 
different old and new versions of the call switch_to.frame 
' '' 
# browers_driver.get ( "HTTPS: / /www.douban.com ") 
# the time.sleep (. 5) 
# Elementi = browers_driver.find_element_by_xpath (" // iframes [@ frameborder = '0'] ") 
# browers_driver.switch_to.frame (Elementi) 
#browers_driver.find_element_by_name = A ( 'Remember') 
# a.click () 
'' ' 
drop-down box to select: pull-down box hide, into a "visible" visibility attribute with the value of the style of js 
' '' 
from selenium.webdriver .support.ui   Import the Select 
browers_driver.get ( " http://news.sina.com.cn/c/2020-01-08/doc-iihnzahk2833225.shtml " ) 
JS = ' document.querySelectorAll ( "SELECT") [ 0] .style.visibility = "visible"; ' 
browers_driver.execute_script (JS) 
selectbtn = the Select (browers_driver.find_element_by_tag_name ( ' SELECT ' )) 
selectbtn.select_by_index(2)

 

Guess you like

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