2

我正在使用Protractor.Net并且遇到了一个奇怪的 IE 问题。我相信这个问题与网站引导有关,但知识不够,无法弄清楚。但是,相同的代码在Chrome和上运行良好Firefox

我在同一页面上执行了两个不同的测试。我的应用程序是non-angularangualr混合的。导航到 Angular 页面后,第一次测试执行没有任何问题。为了测试需要,我再次导航到相同的url位置,当我尝试这样做时,它会崩溃。附件也可在Imgur Imgur Imgur 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()));
4

1 回答 1

1

我实际上在项目中发现了一个错误。在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;
    }
}
于 2015-01-31T06:35:19.220 回答