selenium 模拟浏览器

http://www.testclass.net/selenium_python/mouse-event

# class name里不能有空格,需要把空格替换成.

悬停操作使用
from selenium.webdriver import ActionChains

ActionChains(driver).move_to_element(element).click().perform()

如果窗口最小化,可能会影响flash刷新,比如点击下一个课程,flash黑屏,等到激活窗口才会开始播放。所以有时候不能最小化窗口,我们使用driver.set_position把窗口移动到我们看不到的位置即可

浏览器自动启用flash

https://www.jianshu.com/p/a2baed771055

如果某个网站下面引用了另一个网站,那selenium的driver里无法直接获取这个引用,需要切换iframe

https://blog.csdn.net/huilan_same/article/details/52200586

我们可以使用Js脚本进行模拟点击,使用document.getElementsByClassName('xxx')[0] 按照Index去获取

js DOM方法https://www.w3school.com.cn/js/js_htmldom_methods.asp 

记录cokies模拟登陆

如何设置谷歌浏览器?https://stackoverflow.com/questions/57503188/python-selenium-cant-find-elements-from-page-source-while-can-find-from-browse

https://www.cnblogs.com/Lara1798/p/12944176.html

如何让窗口保持再background?

https://stackoverflow.com/questions/16180428/can-selenium-webdriver-open-browser-windows-silently-in-background

【注】使用docker运行selenium
https://github.com/joyzoursky/docker-python-chromedriver


headless模式:

chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
# driver = webdriver.Chrome(chrome_options=chrome_options) # 设置不加载图片
driver = webdriver.Chrome(r'C:rowser_driverchromedriver1.exe', options=chrome_options) # 设置不加载图片
原文地址:https://www.cnblogs.com/yjybupt/p/13255056.html