3

I am new to protractor & using Protractor-net. Getting an "Asynchronous script timeout: result not received in 0 seconds" exception when running Protractor-net scripts.

https://github.com/bbaia/protractor-net

Does this mean the parameter passing to identify angular element is wrong?

Found this solution to solve this - https://github.com/angular/protractor/issues/117

How do I achieve the same in protractor-net?

ReuseAutomator
  • 410
  • 3
  • 14

1 Answers1

6

You need to set async timeout to increase the timeout if you don't want it to be 0 and do it wherever the driver is instantiated. It is particularly essential due to the nature of Angular's asynchronous behavior.

[SetUp]
public void SetUp()
{
    //driver = new PhantomJSDriver();
    driver = new ChromeDriver();
    //SetScriptTimeout is the asysn script timeout
    driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(5));
}

See this

Saifur
  • 16,081
  • 6
  • 49
  • 73
  • I have done that in my SetUp module. I had set ScriptTimeout to 10 seconds actually. Increasing it too did not solve the issue. Protractor code: _ngDriver.FindElement(NgBy.Binding("category.managed.value + category.unmanaged.value | noFractionCurrency")).Text; – ReuseAutomator Mar 17 '15 at 05:52
  • The actual issue can be somewhere else. How are you binding the angular page? – Saifur Mar 17 '15 at 05:53
  • Its failing here in NgWebDriver.cs - this.jsExecutor.ExecuteAsyncScript(ClientSideScripts.WaitForAngular, this.rootElement) – ReuseAutomator Mar 17 '15 at 06:05
  • In html binding angular displayed - td class="ng-binding" $48,192 td. In ng-View-passing the expression {{managed.total | noFractionCurrency}} as this value is dynamic. So the value 48322 is dynamic. I am just trying to capture that text 48,322. – ReuseAutomator Mar 17 '15 at 06:27
  • driver = new ChromeDriver(); driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10)); angDriver = new NgWebDriver(driver); I use angDriver.WrappedDriver on non-angular pages – ReuseAutomator Mar 17 '15 at 06:37
  • In the above example-you are using PhantomJSDriver, but I am not implementing so. Don't think that will cause any issue, but just mentioning. – ReuseAutomator Mar 17 '15 at 06:43
  • @Chan1385 not really. Ipersonally use this. You do need the script time out no matter what driver you use. And I am afraid the problem is somewhere else not here. Unless you give me more code cannot be determined what's the issue. I do mix ngdriver and webdriver and they both play well together – Saifur Mar 17 '15 at 11:05
  • I am following POM design pattern. In Test class file- public class Navigation : SuperUnit { LoginPg login; [Test] public void TestLogin() { Assets ast = new Assets(SuperUnit.angDriver); ast.ClickManagedAccounts();} public class Assets : SuperUnit { NgWebDriver _ngDriver; public Assets(NgWebDriver _ngDriver) this._ngDriver = _ngDriver; public void ClickManagedAccounts() {string ans = _ngDriver.FindElement(NgBy.Binding("managed")).Text;} Code for SuperUnit provided in earlier comments above. – ReuseAutomator Mar 17 '15 at 23:21
  • Using constructors for each page-In this case Assets, to initialize the driver. Value passed from SuperClass SuperUnit - angDriver = new NgWebDriver(driver) – ReuseAutomator Mar 17 '15 at 23:26
  • Are you able to run any of the test with NgWebDriver? – Saifur Mar 17 '15 at 23:26
  • Since Login page is non-angular, this is the first angular element tried. So NgWebDriver No, but NgDriver. WrappedDriver-Yes. There are two things - either the binding element(manged) passed is wrong-In this case what is the exception thrown in protractor like NoSuchElemntException in Selenium or the way bind Angular is wrong. – ReuseAutomator Mar 17 '15 at 23:44
  • Also referring to this blog by Anthony chu- http://anthonychu.ca/post/end-to-end-testing-angular-apps-with-nunit-and-specflow-using-protractornet/ – ReuseAutomator Mar 17 '15 at 23:50
  • Yes. the `WrappedDriver` is basically nothing but legacy `webdriver`. I can pretty much tell you the trick is how you navigate to angular page from non-angular page. I ran into the same issue. Let me see if I can find any site to show you an example – Saifur Mar 18 '15 at 00:13
  • Also there is slight change in url from login to Asset screen, hence i passed the new url in Page classes and waiting for angular in constructor-_ngDriver.Url = url; – ReuseAutomator Mar 18 '15 at 00:19
  • @Chan1385 See [this](http://screencast.com/t/V9QWVHSbXJ2Q). When you instantiate the `NgWebDriver` you definitely have to bind the angular page with the `NgWebDriver ` in order it to know the the page is angular page and then you have to navigate to the `url` with same driver instance. – Saifur Mar 18 '15 at 00:37
  • If you still having issue see [this](https://letmedothat.wordpress.com/2015/03/18/meet-ngwebdriver-handling-driver-instances/) – Saifur Mar 18 '15 at 02:54
  • Still unable to solve it,probably as login page is non-angular & others angular.So,unable to launch url as well as looking for angular.Raised one more question-http://stackoverflow.com/questions/29116173/protractor-net-non-angular-login-page – ReuseAutomator Mar 18 '15 at 07:23
  • 1
    @Saifur-Thanks for your support. I was working on different assignment for some time. The angular stuff are being recognized now by using Protractor-Net. I had to pass angDriver.IgnoreSynchronization=true in my code. – ReuseAutomator Apr 07 '15 at 03:23
  • Ahh. Glad you have that worked out. Just heads up The protractor-net has been updated to v5.0. You may want to fetch the updates probably – Saifur Apr 07 '15 at 03:26