美文网首页
selenium行为链

selenium行为链

作者: 徒手說梦话 | 来源:发表于2019-02-16 12:05 被阅读0次
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

driver_path = r'D:\python\geckodriver-v0.23.0-win64\geckodriver.exe'
driver = webdriver.Firefox(executable_path=driver_path)
driver.get("https://www.baidu.com/")

inputTag = driver.find_element_by_id('kw')
sumbmitBtn = driver.find_element_by_xpath('//input[@id="su"]')

action = ActionChains(driver)
action.move_to_element(inputTag)
action.send_keys_to_element(inputTag,'python')
action.move_to_element(sumbmitBtn)
action.click(sumbmitBtn)
action.perform() # 执行行为动作

相关文章

网友评论

      本文标题:selenium行为链

      本文链接:https://www.haomeiwen.com/subject/ckubeqtx.html