您的位置:首页 > 其它

Selenium3.0在火狐、IE11运行的注意事项

2016-12-08 16:58 281 查看


1、IE11报Unable to get browser的错误,官方解决方案:


Required Configuration

The IEDriverServer exectuable must be downloaded and
placed in your PATH.
On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone.
To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".
Additionally, "Enhanced Protected Mode" must be disabled for IE 10 and higher. This option is found in the Advanced tab of the Internet Options dialog.
The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer
it creates. For 32-bit Windows installations, the key you must examine in the registry editor is 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
.
For 64-bit Windows installations, the key is 
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
. Please note that
the 
FEATURE_BFCACHE 
subkey may or may not be present, and should be created if it is not present. Important: Inside this
key, create a DWORD value named 
iexplore.exe
 with the value of 0.

2、在火狐浏览器中执行,需要下载最新版本火狐浏览器,并且下载geckodriver.exe,放入火狐安装目录,把目录加入path变量中即可。

第二种办法当然就是使用限制的selenium3.0的版本,由于不在默认支持火狐浏览器,且  Message: 'geckodriver' executable needs to be in PATH  这个错误大家应该

        都不陌生了,问题如看到的一样,需要名为geckodriver.exe的一个火狐浏览器driver在path中,当然解决办法就是,下载一个geckodriver.exe并将存放的路径添加在path中,简单点就

        直接放python的根目录下即可,下载地址 https://github.com/mozilla/geckodriver/releases,另外需要注意下,geckodriver分32及64位的版本,版本需与浏览器对应。当你看到如下报错时,Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided,
and no binary flag set on the command line, 说明你的火狐浏览器和driver版本没有对应上,需确保火狐及driver都是32位或64位的。

   3、    顺便提一下,很多人现在使用的robotframework版本及ride版本都比较落后,先说明下robotframework版本最新为3.0,ride的版本为1.5.2.1.所以引起打不开浏览器如果

        上面的已经做了,仍然打不开,框架升级,需要同步升级一下工具

          pip install -U robotframework

       pip install -U robotframework-ride

       pip install -U robotframework-selenium2library

    总结下,如果使用selenium2.x的版本,需火狐浏览器为47及以下的版本,如果使用selenium3.0,需确保下载有geckodriver且路径在path中。目前selenium3.0支持火狐45及以上的版本。目前最新的火狐浏览器为49。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: