Python使用selenium(二)

时间:2018-12-04 16:10:15   收藏:0   阅读:203

1.selenium鼠标事件

from selenium import webdriver
b=webdriver.Firefox()

url=‘http://www.baidu.com‘
b.get(url)

ele=b.find_element_by_id(‘test‘)

from selenium.webdriver.common.action_chains  import  ActionChains

ActionChains(b) 用于生成模拟用户行为

perform() 执行存储行为

技术分享图片

 将鼠标放到元素上

ActionChains(b).move_to_element(ele).perform()

 

2.键盘事件

from  selenium.webdriver.common.keys  import Keys

技术分享图片

模拟键盘正常输入字符

ele.send_keys("asdfj")   

 

原文:https://www.cnblogs.com/mayyan/p/10064554.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!