2016-07-19 119 views
0

啓動IE瀏覽器,我無法啓動IE瀏覽器運行在C#編寫我的硒自動化測試。無法使用硒的webdriver用C#

我知道這個問題是我沒有設置爲相同級別的安全設置。

我也知道,正常解決這個問題的方法是簡單地選擇在IE瀏覽器的安全選項卡中的所有區域相同的安全級別。但我的工作使安全標籤對我無效。有沒有人知道這個問題的另一個解決方法?

//Start Opening browser 
DesiredCapabilities caps = DesiredCapabilities.InternetExplorer(); 
caps.SetCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); 
driver = new InternetExplorerDriver(caps); 
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);  
driver.Manage().Window.Maximize(); 
driver.Navigate().GoToUrl(this.baseURL); 

預先感謝您!

回答

0

實測值的溶液中。除了忽略保護模式設置,我也忽略縮放設置和點擊不起作用,所以我也忽略本地事件。

這是新代碼:

var options = new InternetExplorerOptions() 
{ 
    InitialBrowserUrl = baseURL, 
    IntroduceInstabilityByIgnoringProtectedModeSettings = true, 
    IgnoreZoomLevel = true, 
    EnableNativeEvents = false 
}; 

driver = new InternetExplorerDriver(options);  
driver.Manage().Window.Maximize(); 
driver.Navigate().GoToUrl(this.baseURL); 
0

是的,你可以使用DesiredCapabilities類硒的webdriver

IE司機//設置能力,忽略所有區域的瀏覽器保護模式設置的做到這一點。

DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); 
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); 

//使用新功能初始化InternetExplorerDriver實例。

WebDriver driver = new InternetExplorerDriver(caps); 
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); 

希望同樣的代碼適合你。

+1

我得到的錯誤「OpenQA.Selenium.IE.InternetExplorerDriver」不包含定義「INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS」 – EEdwards

+0

你能發佈您的代碼在這裏?您使用的是哪個版本的IE驅動程序? – Naseem

+0

我使用IEDriverServer_x64_2.53.1作爲我的代碼,我會更新我的帖子,包括一些。 – EEdwards