Random Selenium E2e Tests Fail because of timeouts on Azure DevOps but work locally and with remote Selenium...












7















I've got a suite of Selenium tests that work perfectly in my local environment and using Browserstack Automate, but fail on Azure DevOps.



There are no configuration or setting changes when running on Azure Devops.



We've followed all the documentation here: https://docs.microsoft.com/en-us/azure/devops/pipelines/test/continuous-test-selenium?view=vsts



Random tests fail, never the same ones.



The tests always fail because of timeouts. I wait for the pages to load for 5 minutes so it's not a case of the timeouts being too low.



There are no firewalls in place, the application is public.



Authentication always succeeds so the tests are able to load the application.



Not sure what to try next.



Below is a copy of the Azure DevOps log. 4 tests passed but all the other's failed. Usually, only 4-5 tests fail.



This tests works perfectly using BrowserStack Automate (remote selenium) and locally.



2018-11-17T05:40:28.6300135Z  Failed   StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending
2018-11-17T05:40:28.6300461Z Error Message:
2018-11-17T05:40:28.6304198Z Test method CS.Portal.E2e.Tests.Admin.StripeAdmin.StripeAdminTests.StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending threw exception:
2018-11-17T05:40:28.6305677Z OpenQA.Selenium.WebDriverTimeoutException: Timed out after 300 seconds
2018-11-17T05:40:28.6307041Z Stack Trace:
2018-11-17T05:40:28.6307166Z at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
2018-11-17T05:40:28.6307999Z at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
2018-11-17T05:40:28.6308188Z at CS.Portal.E2e.Tests.Utility.WebDriverUtilities.WaitForElement(IWebDriver driver, By by, Boolean mustBeDisplayed) in D:a1sCS.Portal.E2e.TestsUtilityWebDriverUtilities.cs:line 26
2018-11-17T05:40:28.6319651Z at CS.Portal.E2e.Tests.Admin.StripeAdmin.StripeAdminTests.StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending() in D:a1sCS.Portal.E2e.TestsAdminStripeAdminStripeAdminTests.cs:line 51
2018-11-17T05:40:28.6319982Z
2018-11-17T05:40:34.4671568Z Results File: D:a1sTestResultsVssAdministrator_factoryvm-az416_2018-11-17_03_08_24.trx
2018-11-17T05:40:34.4692222Z
2018-11-17T05:40:34.4695222Z Attachments:
2018-11-17T05:40:34.4697610Z D:a1sTestResults672f4d28-5082-42e9-a7e7-f5645aadcfd8VssAdministrator_factoryvm-az416 2018-11-17 03_02_43.coverage
2018-11-17T05:40:34.4697943Z
2018-11-17T05:40:34.4698278Z Total tests: 34. Passed: 4. Failed: 30. Skipped: 0.









share|improve this question

























  • Is there a common exception when the tests fails?

    – Guy
    Nov 7 '18 at 14:00











  • Do you use Hosted agent or Private agent?

    – Shayki Abramczyk
    Nov 7 '18 at 14:47











  • @Guy Hosted, the exceptions are always timeouts.

    – jfar
    Nov 7 '18 at 15:16











  • The timeout occurs only in page loading? or in driver.findElement() as well?

    – Guy
    Nov 15 '18 at 14:16













  • @jfar Update the question with your code trials and error stack trace

    – DebanjanB
    Nov 18 '18 at 17:07


















7















I've got a suite of Selenium tests that work perfectly in my local environment and using Browserstack Automate, but fail on Azure DevOps.



There are no configuration or setting changes when running on Azure Devops.



We've followed all the documentation here: https://docs.microsoft.com/en-us/azure/devops/pipelines/test/continuous-test-selenium?view=vsts



Random tests fail, never the same ones.



The tests always fail because of timeouts. I wait for the pages to load for 5 minutes so it's not a case of the timeouts being too low.



There are no firewalls in place, the application is public.



Authentication always succeeds so the tests are able to load the application.



Not sure what to try next.



Below is a copy of the Azure DevOps log. 4 tests passed but all the other's failed. Usually, only 4-5 tests fail.



This tests works perfectly using BrowserStack Automate (remote selenium) and locally.



2018-11-17T05:40:28.6300135Z  Failed   StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending
2018-11-17T05:40:28.6300461Z Error Message:
2018-11-17T05:40:28.6304198Z Test method CS.Portal.E2e.Tests.Admin.StripeAdmin.StripeAdminTests.StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending threw exception:
2018-11-17T05:40:28.6305677Z OpenQA.Selenium.WebDriverTimeoutException: Timed out after 300 seconds
2018-11-17T05:40:28.6307041Z Stack Trace:
2018-11-17T05:40:28.6307166Z at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
2018-11-17T05:40:28.6307999Z at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
2018-11-17T05:40:28.6308188Z at CS.Portal.E2e.Tests.Utility.WebDriverUtilities.WaitForElement(IWebDriver driver, By by, Boolean mustBeDisplayed) in D:a1sCS.Portal.E2e.TestsUtilityWebDriverUtilities.cs:line 26
2018-11-17T05:40:28.6319651Z at CS.Portal.E2e.Tests.Admin.StripeAdmin.StripeAdminTests.StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending() in D:a1sCS.Portal.E2e.TestsAdminStripeAdminStripeAdminTests.cs:line 51
2018-11-17T05:40:28.6319982Z
2018-11-17T05:40:34.4671568Z Results File: D:a1sTestResultsVssAdministrator_factoryvm-az416_2018-11-17_03_08_24.trx
2018-11-17T05:40:34.4692222Z
2018-11-17T05:40:34.4695222Z Attachments:
2018-11-17T05:40:34.4697610Z D:a1sTestResults672f4d28-5082-42e9-a7e7-f5645aadcfd8VssAdministrator_factoryvm-az416 2018-11-17 03_02_43.coverage
2018-11-17T05:40:34.4697943Z
2018-11-17T05:40:34.4698278Z Total tests: 34. Passed: 4. Failed: 30. Skipped: 0.









share|improve this question

























  • Is there a common exception when the tests fails?

    – Guy
    Nov 7 '18 at 14:00











  • Do you use Hosted agent or Private agent?

    – Shayki Abramczyk
    Nov 7 '18 at 14:47











  • @Guy Hosted, the exceptions are always timeouts.

    – jfar
    Nov 7 '18 at 15:16











  • The timeout occurs only in page loading? or in driver.findElement() as well?

    – Guy
    Nov 15 '18 at 14:16













  • @jfar Update the question with your code trials and error stack trace

    – DebanjanB
    Nov 18 '18 at 17:07
















7












7








7


1






I've got a suite of Selenium tests that work perfectly in my local environment and using Browserstack Automate, but fail on Azure DevOps.



There are no configuration or setting changes when running on Azure Devops.



We've followed all the documentation here: https://docs.microsoft.com/en-us/azure/devops/pipelines/test/continuous-test-selenium?view=vsts



Random tests fail, never the same ones.



The tests always fail because of timeouts. I wait for the pages to load for 5 minutes so it's not a case of the timeouts being too low.



There are no firewalls in place, the application is public.



Authentication always succeeds so the tests are able to load the application.



Not sure what to try next.



Below is a copy of the Azure DevOps log. 4 tests passed but all the other's failed. Usually, only 4-5 tests fail.



This tests works perfectly using BrowserStack Automate (remote selenium) and locally.



2018-11-17T05:40:28.6300135Z  Failed   StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending
2018-11-17T05:40:28.6300461Z Error Message:
2018-11-17T05:40:28.6304198Z Test method CS.Portal.E2e.Tests.Admin.StripeAdmin.StripeAdminTests.StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending threw exception:
2018-11-17T05:40:28.6305677Z OpenQA.Selenium.WebDriverTimeoutException: Timed out after 300 seconds
2018-11-17T05:40:28.6307041Z Stack Trace:
2018-11-17T05:40:28.6307166Z at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
2018-11-17T05:40:28.6307999Z at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
2018-11-17T05:40:28.6308188Z at CS.Portal.E2e.Tests.Utility.WebDriverUtilities.WaitForElement(IWebDriver driver, By by, Boolean mustBeDisplayed) in D:a1sCS.Portal.E2e.TestsUtilityWebDriverUtilities.cs:line 26
2018-11-17T05:40:28.6319651Z at CS.Portal.E2e.Tests.Admin.StripeAdmin.StripeAdminTests.StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending() in D:a1sCS.Portal.E2e.TestsAdminStripeAdminStripeAdminTests.cs:line 51
2018-11-17T05:40:28.6319982Z
2018-11-17T05:40:34.4671568Z Results File: D:a1sTestResultsVssAdministrator_factoryvm-az416_2018-11-17_03_08_24.trx
2018-11-17T05:40:34.4692222Z
2018-11-17T05:40:34.4695222Z Attachments:
2018-11-17T05:40:34.4697610Z D:a1sTestResults672f4d28-5082-42e9-a7e7-f5645aadcfd8VssAdministrator_factoryvm-az416 2018-11-17 03_02_43.coverage
2018-11-17T05:40:34.4697943Z
2018-11-17T05:40:34.4698278Z Total tests: 34. Passed: 4. Failed: 30. Skipped: 0.









share|improve this question
















I've got a suite of Selenium tests that work perfectly in my local environment and using Browserstack Automate, but fail on Azure DevOps.



There are no configuration or setting changes when running on Azure Devops.



We've followed all the documentation here: https://docs.microsoft.com/en-us/azure/devops/pipelines/test/continuous-test-selenium?view=vsts



Random tests fail, never the same ones.



The tests always fail because of timeouts. I wait for the pages to load for 5 minutes so it's not a case of the timeouts being too low.



There are no firewalls in place, the application is public.



Authentication always succeeds so the tests are able to load the application.



Not sure what to try next.



Below is a copy of the Azure DevOps log. 4 tests passed but all the other's failed. Usually, only 4-5 tests fail.



This tests works perfectly using BrowserStack Automate (remote selenium) and locally.



2018-11-17T05:40:28.6300135Z  Failed   StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending
2018-11-17T05:40:28.6300461Z Error Message:
2018-11-17T05:40:28.6304198Z Test method CS.Portal.E2e.Tests.Admin.StripeAdmin.StripeAdminTests.StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending threw exception:
2018-11-17T05:40:28.6305677Z OpenQA.Selenium.WebDriverTimeoutException: Timed out after 300 seconds
2018-11-17T05:40:28.6307041Z Stack Trace:
2018-11-17T05:40:28.6307166Z at OpenQA.Selenium.Support.UI.DefaultWait`1.ThrowTimeoutException(String exceptionMessage, Exception lastException)
2018-11-17T05:40:28.6307999Z at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
2018-11-17T05:40:28.6308188Z at CS.Portal.E2e.Tests.Utility.WebDriverUtilities.WaitForElement(IWebDriver driver, By by, Boolean mustBeDisplayed) in D:a1sCS.Portal.E2e.TestsUtilityWebDriverUtilities.cs:line 26
2018-11-17T05:40:28.6319651Z at CS.Portal.E2e.Tests.Admin.StripeAdmin.StripeAdminTests.StripeAdmin_WhenOnTab_DefaultSortIsByIdDescending() in D:a1sCS.Portal.E2e.TestsAdminStripeAdminStripeAdminTests.cs:line 51
2018-11-17T05:40:28.6319982Z
2018-11-17T05:40:34.4671568Z Results File: D:a1sTestResultsVssAdministrator_factoryvm-az416_2018-11-17_03_08_24.trx
2018-11-17T05:40:34.4692222Z
2018-11-17T05:40:34.4695222Z Attachments:
2018-11-17T05:40:34.4697610Z D:a1sTestResults672f4d28-5082-42e9-a7e7-f5645aadcfd8VssAdministrator_factoryvm-az416 2018-11-17 03_02_43.coverage
2018-11-17T05:40:34.4697943Z
2018-11-17T05:40:34.4698278Z Total tests: 34. Passed: 4. Failed: 30. Skipped: 0.






c# selenium selenium-webdriver azure-devops webdriverwait






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 14:30









DebanjanB

42k84080




42k84080










asked Nov 7 '18 at 13:56









jfarjfar

22.4k1066103




22.4k1066103













  • Is there a common exception when the tests fails?

    – Guy
    Nov 7 '18 at 14:00











  • Do you use Hosted agent or Private agent?

    – Shayki Abramczyk
    Nov 7 '18 at 14:47











  • @Guy Hosted, the exceptions are always timeouts.

    – jfar
    Nov 7 '18 at 15:16











  • The timeout occurs only in page loading? or in driver.findElement() as well?

    – Guy
    Nov 15 '18 at 14:16













  • @jfar Update the question with your code trials and error stack trace

    – DebanjanB
    Nov 18 '18 at 17:07





















  • Is there a common exception when the tests fails?

    – Guy
    Nov 7 '18 at 14:00











  • Do you use Hosted agent or Private agent?

    – Shayki Abramczyk
    Nov 7 '18 at 14:47











  • @Guy Hosted, the exceptions are always timeouts.

    – jfar
    Nov 7 '18 at 15:16











  • The timeout occurs only in page loading? or in driver.findElement() as well?

    – Guy
    Nov 15 '18 at 14:16













  • @jfar Update the question with your code trials and error stack trace

    – DebanjanB
    Nov 18 '18 at 17:07



















Is there a common exception when the tests fails?

– Guy
Nov 7 '18 at 14:00





Is there a common exception when the tests fails?

– Guy
Nov 7 '18 at 14:00













Do you use Hosted agent or Private agent?

– Shayki Abramczyk
Nov 7 '18 at 14:47





Do you use Hosted agent or Private agent?

– Shayki Abramczyk
Nov 7 '18 at 14:47













@Guy Hosted, the exceptions are always timeouts.

– jfar
Nov 7 '18 at 15:16





@Guy Hosted, the exceptions are always timeouts.

– jfar
Nov 7 '18 at 15:16













The timeout occurs only in page loading? or in driver.findElement() as well?

– Guy
Nov 15 '18 at 14:16







The timeout occurs only in page loading? or in driver.findElement() as well?

– Guy
Nov 15 '18 at 14:16















@jfar Update the question with your code trials and error stack trace

– DebanjanB
Nov 18 '18 at 17:07







@jfar Update the question with your code trials and error stack trace

– DebanjanB
Nov 18 '18 at 17:07














2 Answers
2






active

oldest

votes


















1














Here are some steps I would do :




  1. What helped us in a similar case is to temporarily add a video recorder to tests then watch the test execution process on a VM from start to fail. There could be some clues on a video that help to see what is actually going wrong I was able to find this link for a C# example


  2. Also, I would double check to make sure browser versions on Azure are exactly the same as in the run where it all works well. Making them the same is crucial to make sure there is no 'magic'. Same for the default browser window size.



  3. I would do more detailed analysis of places where different tests fail.




    • is it possible to spot the similarities between different test failures. Does it always happen after clicks? after reloading pages? after anything else that is similar? If yes - try with the weirdest yet simple and sometimes lifesaving solution and add a 3-5 sec sleep before/after an action that is before the failure. (add sleeps with a condition to only happen when it's an Azzure run) (yes, sleeps are not recommended and {a lot of well-known info why they are not recommended could have been here} but... if they magically save your runs you can then replace them with some smart waits for sure)

    • is it possible that failures happen at some certain time? After same time after run start? At the same time during the day?



  4. If you use Date/time APIs in your code, make sure the System time/locale/timezone settings are exactly the same. Or that the days do not change during the test runs. All in all - investigate around dates.



I know that the above is more like a general advice, but from my experience such "random failures" could be caused by literally anything that seems "not worth attention".






share|improve this answer

































    4





    +150









    A few lines from your code block would have helped to analyze your issue in a better way.



    However, as your tests always fail because of timeouts it is worth to mention that, in general TimeoutException is the outcome of failed ExpectedConditions. However there can be other issues as well.



    Some of the approaches to avoid these issues are as follows:




    • As you mentioned, I wait for the pages to load for 5 minutes... that would be against all the best practices. Instead you need to implement PageLoad, ImplicitWait or WebDriverWait



    WARNING: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times.





    • You can find a detailed discussion in How can I make sure if some HTML elements are loaded for Selenium



    • If you are using ChromeDriver and Chrome Browser you must ensure that the binaries are compatible as per the entries below:





      • ChromeDriver v2.44 : Supports Chrome v69-71 (same as ChromeDriver 2.43, but with additional bug fixes, released Nov 20, 2018)


      • ChromeDriver v2.43 : Supports Chrome v69-71


      • ChromeDriver v2.42 : Supports Chrome v68-70


      • ChromeDriver v2.41 : Supports Chrome v67-69



    • Different Browsers renders the HTML DOM differently. So you need to ensure that the Locator Strategies which you are using are optimized.

    • As per the current WebDriver-W3C Recommendation the following is the list of preferred Locator Strategies:


    Locator Strategies_W3C




    • There is some difference in the performance using CssSelector and XPath. A few take aways:


      • For starters there is no dramatic difference in performance between XPath and CSS.

      • Traversing the DOM in older browsers like IE8 does not work with CSS but is fine with XPath. And XPath can walk up the DOM (e.g. from child to parent), whereas CSS can only traverse down the DOM (e.g. from parent to child). However not being able to traverse the DOM with CSS in older browsers isn't necessarily a bad thing as it is more of an indicator that your page has poor design and could benefit from some helpful markup.

      • An argument in favor of CSS is that they are more readable, brief, and concise while it is a subjective call.


      • Ben Burton mentions you should use CSS because that's how applications are built. This makes the tests easier to write, talk about, and have others help maintain.


      • Adam Goucher says to adopt a more hybrid approach -- focusing first on IDs, then CSS, and leveraging XPath only when you need it (e.g. walking up the DOM) and that XPath will always be more powerful for advanced locators.

      • You can find a detailed discussion in Why should I ever use CSS selectors as opposed to XPath for automated testing?






    Conclusion



    Keeping the above mentioned factors in consideration you need to implement the Locator Strategy wisely along with the other approaches discussed above which will help you to get rid of the timeouts.






    share|improve this answer
























    • I appreciate the effort you put into this answer but it is not helpful. The tests run fine running locally and running with remote Selenium on browserstack. The tests only fail in the Azure Dev Ops environment. The code is using WebDriverWaits already which should be apparent via the stack trace on the 6th and 7th lines of the logs Thank you for the effort though.

      – jfar
      Nov 20 '18 at 21:34













    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53190909%2frandom-selenium-e2e-tests-fail-because-of-timeouts-on-azure-devops-but-work-loca%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Here are some steps I would do :




    1. What helped us in a similar case is to temporarily add a video recorder to tests then watch the test execution process on a VM from start to fail. There could be some clues on a video that help to see what is actually going wrong I was able to find this link for a C# example


    2. Also, I would double check to make sure browser versions on Azure are exactly the same as in the run where it all works well. Making them the same is crucial to make sure there is no 'magic'. Same for the default browser window size.



    3. I would do more detailed analysis of places where different tests fail.




      • is it possible to spot the similarities between different test failures. Does it always happen after clicks? after reloading pages? after anything else that is similar? If yes - try with the weirdest yet simple and sometimes lifesaving solution and add a 3-5 sec sleep before/after an action that is before the failure. (add sleeps with a condition to only happen when it's an Azzure run) (yes, sleeps are not recommended and {a lot of well-known info why they are not recommended could have been here} but... if they magically save your runs you can then replace them with some smart waits for sure)

      • is it possible that failures happen at some certain time? After same time after run start? At the same time during the day?



    4. If you use Date/time APIs in your code, make sure the System time/locale/timezone settings are exactly the same. Or that the days do not change during the test runs. All in all - investigate around dates.



    I know that the above is more like a general advice, but from my experience such "random failures" could be caused by literally anything that seems "not worth attention".






    share|improve this answer






























      1














      Here are some steps I would do :




      1. What helped us in a similar case is to temporarily add a video recorder to tests then watch the test execution process on a VM from start to fail. There could be some clues on a video that help to see what is actually going wrong I was able to find this link for a C# example


      2. Also, I would double check to make sure browser versions on Azure are exactly the same as in the run where it all works well. Making them the same is crucial to make sure there is no 'magic'. Same for the default browser window size.



      3. I would do more detailed analysis of places where different tests fail.




        • is it possible to spot the similarities between different test failures. Does it always happen after clicks? after reloading pages? after anything else that is similar? If yes - try with the weirdest yet simple and sometimes lifesaving solution and add a 3-5 sec sleep before/after an action that is before the failure. (add sleeps with a condition to only happen when it's an Azzure run) (yes, sleeps are not recommended and {a lot of well-known info why they are not recommended could have been here} but... if they magically save your runs you can then replace them with some smart waits for sure)

        • is it possible that failures happen at some certain time? After same time after run start? At the same time during the day?



      4. If you use Date/time APIs in your code, make sure the System time/locale/timezone settings are exactly the same. Or that the days do not change during the test runs. All in all - investigate around dates.



      I know that the above is more like a general advice, but from my experience such "random failures" could be caused by literally anything that seems "not worth attention".






      share|improve this answer




























        1












        1








        1







        Here are some steps I would do :




        1. What helped us in a similar case is to temporarily add a video recorder to tests then watch the test execution process on a VM from start to fail. There could be some clues on a video that help to see what is actually going wrong I was able to find this link for a C# example


        2. Also, I would double check to make sure browser versions on Azure are exactly the same as in the run where it all works well. Making them the same is crucial to make sure there is no 'magic'. Same for the default browser window size.



        3. I would do more detailed analysis of places where different tests fail.




          • is it possible to spot the similarities between different test failures. Does it always happen after clicks? after reloading pages? after anything else that is similar? If yes - try with the weirdest yet simple and sometimes lifesaving solution and add a 3-5 sec sleep before/after an action that is before the failure. (add sleeps with a condition to only happen when it's an Azzure run) (yes, sleeps are not recommended and {a lot of well-known info why they are not recommended could have been here} but... if they magically save your runs you can then replace them with some smart waits for sure)

          • is it possible that failures happen at some certain time? After same time after run start? At the same time during the day?



        4. If you use Date/time APIs in your code, make sure the System time/locale/timezone settings are exactly the same. Or that the days do not change during the test runs. All in all - investigate around dates.



        I know that the above is more like a general advice, but from my experience such "random failures" could be caused by literally anything that seems "not worth attention".






        share|improve this answer















        Here are some steps I would do :




        1. What helped us in a similar case is to temporarily add a video recorder to tests then watch the test execution process on a VM from start to fail. There could be some clues on a video that help to see what is actually going wrong I was able to find this link for a C# example


        2. Also, I would double check to make sure browser versions on Azure are exactly the same as in the run where it all works well. Making them the same is crucial to make sure there is no 'magic'. Same for the default browser window size.



        3. I would do more detailed analysis of places where different tests fail.




          • is it possible to spot the similarities between different test failures. Does it always happen after clicks? after reloading pages? after anything else that is similar? If yes - try with the weirdest yet simple and sometimes lifesaving solution and add a 3-5 sec sleep before/after an action that is before the failure. (add sleeps with a condition to only happen when it's an Azzure run) (yes, sleeps are not recommended and {a lot of well-known info why they are not recommended could have been here} but... if they magically save your runs you can then replace them with some smart waits for sure)

          • is it possible that failures happen at some certain time? After same time after run start? At the same time during the day?



        4. If you use Date/time APIs in your code, make sure the System time/locale/timezone settings are exactly the same. Or that the days do not change during the test runs. All in all - investigate around dates.



        I know that the above is more like a general advice, but from my experience such "random failures" could be caused by literally anything that seems "not worth attention".







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 26 '18 at 12:08

























        answered Nov 21 '18 at 19:35









        Vladimir EfimovVladimir Efimov

        699312




        699312

























            4





            +150









            A few lines from your code block would have helped to analyze your issue in a better way.



            However, as your tests always fail because of timeouts it is worth to mention that, in general TimeoutException is the outcome of failed ExpectedConditions. However there can be other issues as well.



            Some of the approaches to avoid these issues are as follows:




            • As you mentioned, I wait for the pages to load for 5 minutes... that would be against all the best practices. Instead you need to implement PageLoad, ImplicitWait or WebDriverWait



            WARNING: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times.





            • You can find a detailed discussion in How can I make sure if some HTML elements are loaded for Selenium



            • If you are using ChromeDriver and Chrome Browser you must ensure that the binaries are compatible as per the entries below:





              • ChromeDriver v2.44 : Supports Chrome v69-71 (same as ChromeDriver 2.43, but with additional bug fixes, released Nov 20, 2018)


              • ChromeDriver v2.43 : Supports Chrome v69-71


              • ChromeDriver v2.42 : Supports Chrome v68-70


              • ChromeDriver v2.41 : Supports Chrome v67-69



            • Different Browsers renders the HTML DOM differently. So you need to ensure that the Locator Strategies which you are using are optimized.

            • As per the current WebDriver-W3C Recommendation the following is the list of preferred Locator Strategies:


            Locator Strategies_W3C




            • There is some difference in the performance using CssSelector and XPath. A few take aways:


              • For starters there is no dramatic difference in performance between XPath and CSS.

              • Traversing the DOM in older browsers like IE8 does not work with CSS but is fine with XPath. And XPath can walk up the DOM (e.g. from child to parent), whereas CSS can only traverse down the DOM (e.g. from parent to child). However not being able to traverse the DOM with CSS in older browsers isn't necessarily a bad thing as it is more of an indicator that your page has poor design and could benefit from some helpful markup.

              • An argument in favor of CSS is that they are more readable, brief, and concise while it is a subjective call.


              • Ben Burton mentions you should use CSS because that's how applications are built. This makes the tests easier to write, talk about, and have others help maintain.


              • Adam Goucher says to adopt a more hybrid approach -- focusing first on IDs, then CSS, and leveraging XPath only when you need it (e.g. walking up the DOM) and that XPath will always be more powerful for advanced locators.

              • You can find a detailed discussion in Why should I ever use CSS selectors as opposed to XPath for automated testing?






            Conclusion



            Keeping the above mentioned factors in consideration you need to implement the Locator Strategy wisely along with the other approaches discussed above which will help you to get rid of the timeouts.






            share|improve this answer
























            • I appreciate the effort you put into this answer but it is not helpful. The tests run fine running locally and running with remote Selenium on browserstack. The tests only fail in the Azure Dev Ops environment. The code is using WebDriverWaits already which should be apparent via the stack trace on the 6th and 7th lines of the logs Thank you for the effort though.

              – jfar
              Nov 20 '18 at 21:34


















            4





            +150









            A few lines from your code block would have helped to analyze your issue in a better way.



            However, as your tests always fail because of timeouts it is worth to mention that, in general TimeoutException is the outcome of failed ExpectedConditions. However there can be other issues as well.



            Some of the approaches to avoid these issues are as follows:




            • As you mentioned, I wait for the pages to load for 5 minutes... that would be against all the best practices. Instead you need to implement PageLoad, ImplicitWait or WebDriverWait



            WARNING: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times.





            • You can find a detailed discussion in How can I make sure if some HTML elements are loaded for Selenium



            • If you are using ChromeDriver and Chrome Browser you must ensure that the binaries are compatible as per the entries below:





              • ChromeDriver v2.44 : Supports Chrome v69-71 (same as ChromeDriver 2.43, but with additional bug fixes, released Nov 20, 2018)


              • ChromeDriver v2.43 : Supports Chrome v69-71


              • ChromeDriver v2.42 : Supports Chrome v68-70


              • ChromeDriver v2.41 : Supports Chrome v67-69



            • Different Browsers renders the HTML DOM differently. So you need to ensure that the Locator Strategies which you are using are optimized.

            • As per the current WebDriver-W3C Recommendation the following is the list of preferred Locator Strategies:


            Locator Strategies_W3C




            • There is some difference in the performance using CssSelector and XPath. A few take aways:


              • For starters there is no dramatic difference in performance between XPath and CSS.

              • Traversing the DOM in older browsers like IE8 does not work with CSS but is fine with XPath. And XPath can walk up the DOM (e.g. from child to parent), whereas CSS can only traverse down the DOM (e.g. from parent to child). However not being able to traverse the DOM with CSS in older browsers isn't necessarily a bad thing as it is more of an indicator that your page has poor design and could benefit from some helpful markup.

              • An argument in favor of CSS is that they are more readable, brief, and concise while it is a subjective call.


              • Ben Burton mentions you should use CSS because that's how applications are built. This makes the tests easier to write, talk about, and have others help maintain.


              • Adam Goucher says to adopt a more hybrid approach -- focusing first on IDs, then CSS, and leveraging XPath only when you need it (e.g. walking up the DOM) and that XPath will always be more powerful for advanced locators.

              • You can find a detailed discussion in Why should I ever use CSS selectors as opposed to XPath for automated testing?






            Conclusion



            Keeping the above mentioned factors in consideration you need to implement the Locator Strategy wisely along with the other approaches discussed above which will help you to get rid of the timeouts.






            share|improve this answer
























            • I appreciate the effort you put into this answer but it is not helpful. The tests run fine running locally and running with remote Selenium on browserstack. The tests only fail in the Azure Dev Ops environment. The code is using WebDriverWaits already which should be apparent via the stack trace on the 6th and 7th lines of the logs Thank you for the effort though.

              – jfar
              Nov 20 '18 at 21:34
















            4





            +150







            4





            +150



            4




            +150





            A few lines from your code block would have helped to analyze your issue in a better way.



            However, as your tests always fail because of timeouts it is worth to mention that, in general TimeoutException is the outcome of failed ExpectedConditions. However there can be other issues as well.



            Some of the approaches to avoid these issues are as follows:




            • As you mentioned, I wait for the pages to load for 5 minutes... that would be against all the best practices. Instead you need to implement PageLoad, ImplicitWait or WebDriverWait



            WARNING: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times.





            • You can find a detailed discussion in How can I make sure if some HTML elements are loaded for Selenium



            • If you are using ChromeDriver and Chrome Browser you must ensure that the binaries are compatible as per the entries below:





              • ChromeDriver v2.44 : Supports Chrome v69-71 (same as ChromeDriver 2.43, but with additional bug fixes, released Nov 20, 2018)


              • ChromeDriver v2.43 : Supports Chrome v69-71


              • ChromeDriver v2.42 : Supports Chrome v68-70


              • ChromeDriver v2.41 : Supports Chrome v67-69



            • Different Browsers renders the HTML DOM differently. So you need to ensure that the Locator Strategies which you are using are optimized.

            • As per the current WebDriver-W3C Recommendation the following is the list of preferred Locator Strategies:


            Locator Strategies_W3C




            • There is some difference in the performance using CssSelector and XPath. A few take aways:


              • For starters there is no dramatic difference in performance between XPath and CSS.

              • Traversing the DOM in older browsers like IE8 does not work with CSS but is fine with XPath. And XPath can walk up the DOM (e.g. from child to parent), whereas CSS can only traverse down the DOM (e.g. from parent to child). However not being able to traverse the DOM with CSS in older browsers isn't necessarily a bad thing as it is more of an indicator that your page has poor design and could benefit from some helpful markup.

              • An argument in favor of CSS is that they are more readable, brief, and concise while it is a subjective call.


              • Ben Burton mentions you should use CSS because that's how applications are built. This makes the tests easier to write, talk about, and have others help maintain.


              • Adam Goucher says to adopt a more hybrid approach -- focusing first on IDs, then CSS, and leveraging XPath only when you need it (e.g. walking up the DOM) and that XPath will always be more powerful for advanced locators.

              • You can find a detailed discussion in Why should I ever use CSS selectors as opposed to XPath for automated testing?






            Conclusion



            Keeping the above mentioned factors in consideration you need to implement the Locator Strategy wisely along with the other approaches discussed above which will help you to get rid of the timeouts.






            share|improve this answer













            A few lines from your code block would have helped to analyze your issue in a better way.



            However, as your tests always fail because of timeouts it is worth to mention that, in general TimeoutException is the outcome of failed ExpectedConditions. However there can be other issues as well.



            Some of the approaches to avoid these issues are as follows:




            • As you mentioned, I wait for the pages to load for 5 minutes... that would be against all the best practices. Instead you need to implement PageLoad, ImplicitWait or WebDriverWait



            WARNING: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times.





            • You can find a detailed discussion in How can I make sure if some HTML elements are loaded for Selenium



            • If you are using ChromeDriver and Chrome Browser you must ensure that the binaries are compatible as per the entries below:





              • ChromeDriver v2.44 : Supports Chrome v69-71 (same as ChromeDriver 2.43, but with additional bug fixes, released Nov 20, 2018)


              • ChromeDriver v2.43 : Supports Chrome v69-71


              • ChromeDriver v2.42 : Supports Chrome v68-70


              • ChromeDriver v2.41 : Supports Chrome v67-69



            • Different Browsers renders the HTML DOM differently. So you need to ensure that the Locator Strategies which you are using are optimized.

            • As per the current WebDriver-W3C Recommendation the following is the list of preferred Locator Strategies:


            Locator Strategies_W3C




            • There is some difference in the performance using CssSelector and XPath. A few take aways:


              • For starters there is no dramatic difference in performance between XPath and CSS.

              • Traversing the DOM in older browsers like IE8 does not work with CSS but is fine with XPath. And XPath can walk up the DOM (e.g. from child to parent), whereas CSS can only traverse down the DOM (e.g. from parent to child). However not being able to traverse the DOM with CSS in older browsers isn't necessarily a bad thing as it is more of an indicator that your page has poor design and could benefit from some helpful markup.

              • An argument in favor of CSS is that they are more readable, brief, and concise while it is a subjective call.


              • Ben Burton mentions you should use CSS because that's how applications are built. This makes the tests easier to write, talk about, and have others help maintain.


              • Adam Goucher says to adopt a more hybrid approach -- focusing first on IDs, then CSS, and leveraging XPath only when you need it (e.g. walking up the DOM) and that XPath will always be more powerful for advanced locators.

              • You can find a detailed discussion in Why should I ever use CSS selectors as opposed to XPath for automated testing?






            Conclusion



            Keeping the above mentioned factors in consideration you need to implement the Locator Strategy wisely along with the other approaches discussed above which will help you to get rid of the timeouts.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 20 '18 at 10:30









            DebanjanBDebanjanB

            42k84080




            42k84080













            • I appreciate the effort you put into this answer but it is not helpful. The tests run fine running locally and running with remote Selenium on browserstack. The tests only fail in the Azure Dev Ops environment. The code is using WebDriverWaits already which should be apparent via the stack trace on the 6th and 7th lines of the logs Thank you for the effort though.

              – jfar
              Nov 20 '18 at 21:34





















            • I appreciate the effort you put into this answer but it is not helpful. The tests run fine running locally and running with remote Selenium on browserstack. The tests only fail in the Azure Dev Ops environment. The code is using WebDriverWaits already which should be apparent via the stack trace on the 6th and 7th lines of the logs Thank you for the effort though.

              – jfar
              Nov 20 '18 at 21:34



















            I appreciate the effort you put into this answer but it is not helpful. The tests run fine running locally and running with remote Selenium on browserstack. The tests only fail in the Azure Dev Ops environment. The code is using WebDriverWaits already which should be apparent via the stack trace on the 6th and 7th lines of the logs Thank you for the effort though.

            – jfar
            Nov 20 '18 at 21:34







            I appreciate the effort you put into this answer but it is not helpful. The tests run fine running locally and running with remote Selenium on browserstack. The tests only fail in the Azure Dev Ops environment. The code is using WebDriverWaits already which should be apparent via the stack trace on the 6th and 7th lines of the logs Thank you for the effort though.

            – jfar
            Nov 20 '18 at 21:34




















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53190909%2frandom-selenium-e2e-tests-fail-because-of-timeouts-on-azure-devops-but-work-loca%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to send String Array data to Server using php in android

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Is anime1.com a legal site for watching anime?