我正在使用 Protractor.Net 并且IE遇到了一个奇怪的问题。我相信这个问题与网站引导有关,但知识不够多,无法弄清楚。但是,相同的代码在Chrome
和Firefox
上运行良好。
我在同一页面上执行两个不同的测试。我的应用程序是non-angular
和angualr
混合的。导航到 Angular 页面后,第一个测试执行没有任何问题。对于测试需求,我再次导航到相同的url
,当我尝试这样做时,它正在中断。附件也可在Imgur获得伊姆古尔伊姆古尔伊姆古尔
//Navigate and binds the page
public TestPage TestPage()
{
string url = BaseUrl + "/n/Test/TestPage#/";
//need to handle asyn script call timeout
Driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));
NgWebDriver ngDriver = new NgWebDriver(Driver, "[ng-app='Test']");
ngDriver.Navigate().GoToUrl(url);
return new TestPage(ngDriver);
}
// Resume Angular bootstrap this is in URL setter and fails here on second iteration
this.jsExecutor.ExecuteScript(ClientSideScripts.ResumeAngularBootstrap,
String.Join(",", this.mockModules.Select(m => m.Name).ToArray()));
我实际上在项目中发现了一个错误。在属性 setter 之前设置以下行URL
解决了这个问题!
this.driver.Url = "about:blank";
get
{
this.WaitForAngular();
IHasCapabilities hcDriver = this.driver as IHasCapabilities;
if (hcDriver != null && hcDriver.Capabilities.BrowserName == "internet explorer")
{
// 'this.driver.Url' does not work on IE
//this.driver.Url = "about:blank"; //this is bug fix
return this.jsExecutor.ExecuteScript(ClientSideScripts.GetLocationAbsUrl, this.rootElement) as string;
}
else
{
return this.driver.Url;
}
}