请注意,我是一个初学者,这是我在本网站上的第一个问题...因此,如果措辞不当,请提前道歉。
我正在使用IE 11 webDriver的Selenium在C#中进行编码。
我遇到一个问题,我总是在包括Google主页在内的多个页面上加载页面时遇到异常(即使等待2分钟)。
我试图解决这些错误的方法:
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium;
InternetExplorerOptions IEoptions = new InternetExplorerOptions();
IEoptions.PageLoadStrategy = PageLoadStrategy.Eager;
webdriver = new InternetExplorerDriver(IEoptions);
webdriver.Navigate().GoToUrl("http://google.ca");
//This Line returns the error
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium;
private void LoadPage()
{
InternetExplorerOptions IEoptions = new InternetExplorerOptions();
IEoptions.PageLoadStrategy = PageLoadStrategy.None;
webdriver = new InternetExplorerDriver(IEoptions);
webdriver.Navigate().GoToUrl("http://google.ca");
}
private void GetElementPosition()
{
debug.print(webdriver.FindElement(By.Id("gsr")).Location.ToString());
//this line returns the error
}
硒版本:4.0.0
IEwebdriver版本:3.150.1.1
答案 0 :(得分:0)
我在另一篇文章中找到了答案。我的问题实际上是由IE保护模式引起的。
解决方案是手动更改IE选项,或将IE选项更改为“ IntroduceInstabilityByIgnoringProtectedModeSettings”(如果无法使用前一种解决方案)。