selenium环境搭建

前置条件:

1.Windows键+R打开命令提示符

2.输入命令pip list

3.查看selenium是否配置,查看版本是不是3.14.1

4.如果没有,输入pip insert selenium==3.14.1

5.提前安装好谷歌,火狐,edge游览器

火狐游览器环境搭建

1.打开网页链接https://github.com/mozilla/geckodriver/releases

2.找到Windows版本,下载对应的驱动

3.下载之后解压把 geckodriver.exe 的驱动放到python的安装目录下

4.编写测试脚本如下,游览器启动打开表示成功

from selenium import webdriver
dri = webdriver.Firefox()
dri.get('http://www.baidu.com')

谷歌

1.打开谷歌浏览器,在设置里面查看谷歌浏览器的版本

2.打开https://chromedriver.storage.googleapis.com/index.html 链接,找到合适的版本号的驱动,进入下载windows的驱动

3.下载的驱动压缩包解压,然后把 chromedriver.exe 的文件放在python的安装目录下

4.编写脚本进行测试,如下:浏览器启动之后打开百度的页面表示成功

from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.baidu.com')

Edge

 1.打开https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/链接

2.查看Edge浏览器的版本,下载合适的驱动

3.解压驱动之后能看到一个名为msedgedriver.exe的文件,重命名为:MicrosoftWebDriver.exe文件

4.把重命名之后的文件放入python的安装目录

5.编写测试脚本如下,游览器启动表示成功

from selenium import webdriver
driver = webdriver.Edge()
driver.get('http://www.baidu.com')

v2.45.0 ======= * Supports native events for Firefox versions 31 (current ESR), and 24 (immediately previous ESR). Native event support has been discontinued for versions of Firefox later than 33. * Removed automatic installation of SafariDriver extention for .NET. From this point forward, users are expected to manually install the SafariDriver extension into their Safari installation in order to drive the browser. This is due to Apple's changes in architecture for Safari extensions. * Added initial implementation of .NET bindings OperaDriver. The .NET bindings will now support the Chromium-based Opera driver without requiring the use of the Java remote WebDriver server. This driver will work with Opera 26 and above, and requires the download of the Opera driver executable. Code cleanup and refactoring will take place under a separate commit. Note that there is still no support in the .NET bindings for the Presto-based Opera without using the remote server, nor is there likely to be. * Added option to not delete anonymous Firefox profile in .NET. This change adds an option to the .NET FirefoxProfile class so that the driver will not delete the anonymous profile created by the driver. Since the driver cannot and should not use an existing profile in situ because of the multiple instance automation case, this change means that modifications applied to the anonymous profile can be retained and used in future anonymous profiles. The implication is that the user can now make modifications to a profile, and retain those profile modifications (e.g., cookies) into other future profiles, simulating persistent changes over multiple browser launches. Fixes issue #7374. * Introduced type safe option in InternetExplorerOptions to set the capability to disable check of mime type of the doucment when setting cookies. When setting cookies, there is a check in the IE driver to validate that the page in the browser is, in fact, an HTML page. Despite the fact that omitting this check can cause unrecoverable crashes in the driver, there is demand for a mechanism to disable this check for older, legacy versions of Internet Explorer. Fixes issue #1227. v2.44.0 ======= * Supports native events for Firefox versions 33 (current), 32 (immediately previous release), 31 (current ESR), and 24 (immediately previous ESR). * Rolled back improper spec compliance for finding elements. * Fixed WebDriverBackedSelenium compatibility with IE5. Fixes issue #7938. v2.43.1 ======= * Point-release to correct version resources in .NET bindings assemblies. No functional changes. v2.43.0 ======= * Supports native events for Firefox versions 32 (current), 31 (immediately previous release and current ESR), and 24 (immediately previous ESR). * Integrated the Microsoft Internet Explorer driver implementation into the .NET bindings. By setting the Implementation property of the .NET bindings' InternetExplorerDriverService class, the user can now force the driver to use the Microsoft implementation. Note that the default is to use the existing open-source implementation based on the Automation Atoms. Over time as the Microsoft implementation matures, this will be switched to use the Microsoft implementation, first by default, then exclusively. To use the Microsoft implementation, the user must have the August 2014 updates to Internet Explorer installed through Windows Update, and must install the IE Web Driver Tool for Internet Explorer 11 download from Microsoft (http://www.microsoft.com/en-us/download/details.aspx?id=44069). * Added safe check for window.localStorage in .NET WebDriverBackedSelenium implementation. Patch provided by Timofey Vasenin. * Implemented pluggable element locator factories for .NET PageFactory. This change allows the user to specify a custom IElementLocatorFactory for locating elements when used with the PageFactory. This gives much more control over the algorithm used to locate elements, and allows the incorporation of things like retries or handling of specific exceptions. * Issue #7367: Set Json.NET to ignore dates when parsing response values. * Issue #7419: Added support for SwitchTo().ParentFrame() in .NET bindings. This brings the .NET bindings into parity with other languages. * Belatedly removed long-obsolete .NET tests for AndroidDriver.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值