第二十七节 selenium行为链

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


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.common.action_chains import ActionChains
browers_driver.get("http://www.baidu.com")
inputag = browers_driver.find_element_by_id('kw')
submitag = browers_driver.find_element_by_id('su')

actions = ActionChains(browers_driver)
actions.move_to_element(inputag)
actions.send_keys_to_element(inputag,'python')
actions.move_to_element(submitag)
actions.click(submitag)
actions.perform()

 

posted @ 2020-03-16 21:53  kog_maw  阅读(212)  评论(0编辑  收藏  举报