1. 程式人生 > >selenium c# 的註意事項

selenium c# 的註意事項

google bit git eap int windows hub create bfc

http://chromedriver.storage.googleapis.com/index.html chromedriver的下載地址
http://selenium-release.storage.googleapis.com/index.html IEdriver的下載地址
https://github.com/mozilla/geckodriver/releases firefoxdriver的下載地址

問題積累:
1. 關於IE11不能定位的問題:解決方案:
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. (32bit Windows看這裏。)

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.(64bit Windows看這裏。)

翻譯過來的意思即,修改你的註冊表(Run->regedit->Enter),路徑如下:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE

如果FeatureControl下沒有FEATURE_BFCACHE,就以FEATURE_BFCACHE為名new一個key!並在其下創建一個DWORD,取名為:iexplore.exe,value為0。

2. IE的click無效的解決方案:
使用模擬js點擊:
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click();", driver.FindElement(By.TagName("button")));

3. IE的sendkeys慢的解決方案:
IE的64位driver有bug,使用32位的driver

4. firefox中sendkeys報錯的問題
firefox的版本問題,使用52版本的firefox可以解決

selenium c# 的註意事項