一、 这里的学习基于Python3;   由于selenium3不向前支持火狐浏览器,40以后的版本的火狐,运行会出现问题,所以需要——   二、关于Firefox 1. 如果运行后,你发现只打开了浏览器,而没有打开网址。那么多数是版本问题:Selenium版本为3,或者火狐版本太高,一般Selenium2支持46以下的。 现在运行会发现问题,在console中出现的提示是: Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases 这就是要求要安装geckodriver了(支持3.3.1)。   之前版本的Selenium客户端,遵循:W3C WebDriver specification  链接:https://w3c.github.io/webdriver/webdriver-spec.html   解决的办法就是:   1、到官网上下载与系统相应的最新版本geckodriver:https://github.com/mozilla/geckodriver/releases   从2015年4月9日的wires V0.1.0版,直到2017年3月8日的最新V0.15.0,走过了15次的版本更新。   2、解压后,将文件存放到火狐或python的安装目录;   2. 若还是有问题,需要将浏览器更新为最新版本;   三、关于Edge https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads 1. 在上面的网站中下载计算机中Edge浏览器版本对应的MicrosoftWebDriver; 2. 下载成功后将.exe文件放到python/scripts中; 3. edge_driver_path = "E:\program\Python37\Scripts\MicrosoftWebDriver 15.15063.exe" driver = webdriver.Edge(edge_driver_path)   四、 关于Chrome 下载链接: http://chromedriver.storage.googleapis.com/index.html http://npm.taobao.org/mirrors/chromedriver/ 版本问题:https://blog.csdn.net/yoyocat915/article/details/80580066 1. 补充一个ChromeDriver 2.43--》Chrome 69-71   五、 元素校验的方法 浏览器通用: 开发者控制台(console): xpath的方式:$x('/html/body/main/div/div/nav/ul/li[2]') css的方式:$('#su') 火狐:firefinder插件 谷歌:Xpath Helper插件   六、 API查看 https://www.cnblogs.com/SZLLQ2000/p/5407473.html python -m pydoc -p 4567   七、 关于没有引入selenium file--》Project Interpreter: 选择python安装目录下的python.exe后,添加selenium; 1. 工具的基本问题了解 随笔 第1张 八、 解决导入自定义模块出现红色波浪线的问题 file--》setting--》project--》project structure--》对应项目--》Excluded; 1. 工具的基本问题了解 随笔 第2张   九、关于IE浏览器及其驱动 IEDrivrerServer的版本号和selinium版本号一致; 比如现在装的selenium3.14.1版本,那么IE驱动也要是3.14的版本; 下载链接:http://selenium-release.storage.googleapis.com/index.html   十、 关于pycharm shows "PEP:8 expected 2 blank lines ,found 1"的问题 解决办法,在段代码开始前,即def方法开始前与上一段代码空两行; 其他pep8的问题:https://blog.csdn.net/Jason_Lewis/article/details/75386598 忽略pep8代码风格的方法:https://blog.csdn.net/zgljl2012/article/details/51907663
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄