C# Protractor AngularJS IEDriverServer Click() Exc

2019-09-06 02:25发布

I'm using Protractor to test our AngularJS application (with both Chrome and IE drivers). The IEDriverServer works OK on most pages, except for this one page where pretty much all of the Click() event will result in an exception of "Timed out waiting for page to load."

The IE driver options are set as follows:

var ieOptions = new InternetExplorerOptions
{
    BrowserCommandLineArguments = "-private",
    EnableNativeEvents = false,
    IgnoreZoomLevel = true,
    IntroduceInstabilityByIgnoringProtectedModeSettings = false
};

// No Proxy
var proxy = new Proxy()
{
    Kind = ProxyKind.Direct
};

ieOptions.Proxy = proxy;

Also, IgnoreSynchronization = true.

Edited 1: I think the difference between this page and others is its use of Javascript SignalR. I find this code in its head section that is not in the other pages. Can this be the cause of the timeout exceptions and what can I do to make it work?

<script src="https://localhost:37121/signalr/poll?transport=longPolling&amp;connectionToken=AQAAANCMnd8BFdERjHoAwE%2FCl%2BsBAAAAUwalDb1qVUqsBmCLuURNHwAAAAACAAAAAAADZgAAwAAAABAAAADr9g2GQVKvK1pb%2FivxTu%2BBAAAAAASAAACgAAAAEAAAAB5eAALolT7EtoL1Y9C1xPooAAAA3TnUmbajNM9RIJ8oDRsPGLjavLcB2M10CyoJMXrnpv9H9XzB4bRVLBQAAABrEcirF0pjR5t%2Fst0mWJ0MnJYVlA%3D%3D&amp;messageId=d-9774B3D8-B%2C24%7CC%2C0%7CD%2C0%7CE%2C0&amp;connectionData=%5B%7B%22name%22%3A%22devicehub%22%7D%5D&amp;tid=8&amp;callback=jQuery21103819021041958953_1481549049341&amp;_=1481549049371" async=""></script>

Edit 2: It doesn't matter how long I set the ImplicitWait, SetPageLoadTimeout, and SetScriptTimeout to be. The click events will return with an exception after the specified wait time has elapsed.

2条回答
别忘想泡老子
2楼-- · 2019-09-06 03:24

I have had this issue and only solution I found was to make SignalR work with WebSockets, which requires IIS8. In my case SignalR was working with Long Polling, which keep a connection open for a long time. Even if you increase the timeout this will make your tests unacceptably slow. See: SignalR w/ Web Sockets

查看更多
Bombasti
3楼-- · 2019-09-06 03:29

In between your click events, if page is refreshing. Then please check for browser.manage().timeouts().pageLoadTimeout(<timeout in milliseconds>) in your conf.js file.

In C#, there are option for pageLoadTimeout() in below manner:

seleniumDriver.manage().timeouts()
      .pageLoadTimeout(xx, TimeUnit.SECONDS)
      .implicitlyWait(xx, TimeUnit.SECONDS)
      .setScriptTimeout(xx, TimeUnit.SECONDS);

I think you need to look for pageLoadTimeout(), because protractor internally will only wait for the specified time for the page to load. After that it will throw timeout waiting for page to load.

查看更多
登录 后发表回答