0

I have a selenium script that get triggered in an azure pipeline to test some web pages if they are working. The script get triggered every hour in an azure pipeline, but the weird thing is that this script randomly, at least twice a day, it fails because it doesn't find an element. I do believe that this might happen because the pipeline worker is not fast enough to load the pages.

So I was wondering, if there is a way how can I solve this issue as for now the script when it fails its returning a false positive and I would like to avoid this.

thank you so much for any help or advice you can offer

Nayden Van
  • 1,133
  • 1
  • 23
  • 70
  • You could try to increase the timeouts for waits and loads – theNishant Aug 26 '21 at 08:15
  • Sorry, with timeouts you mean the `webDriver wait` right? and another question an I apology because I am not an expert in selenium.. what do you mean with loads? – Nayden Van Aug 26 '21 at 09:39
  • yup I mean to increase the time for Webdriver wait. – theNishant Aug 26 '21 at 09:51
  • you could always test if the element exists instead of trying to access it, and if it doesn't you wait longer – AntiMatterDynamite Aug 26 '21 at 11:47
  • @AntiMatterDynamite that process is not similar to this one? `wait.until(EC.element_to_be_clickable((By.XPATH, xpath)` because now in my script I have this set. – Nayden Van Aug 26 '21 at 11:53
  • I increased the wait web driver up to 40seconds but they still fail sometimes. Is there any way that I can use selenium to wait untill when the page is fully loaded before to start checking the elements? – Nayden Van Aug 26 '21 at 22:07

1 Answers1

-1

To wait until the page is fully loaded, you can check similar ticket for the details.

In addition, for azure devops pipeline, to make it's more stable, you can setup self-hosted agent for the selenium test.

wade zhou - MSFT
  • 1,397
  • 1
  • 3
  • 6
  • Thank you very much for your reply, unfortunately I can use the self hosted agent as I am on a MacOs, do you know if there is any other option to make the agent more stable? – Nayden Van Aug 27 '21 at 08:41
  • You can aslo set up MacOS self-hosted agent: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-osx?view=azure-devops. – wade zhou - MSFT Aug 27 '21 at 09:02
  • Before to move to this stage, I would like to try to take screenshots of where the error is. I can use `driver.save_screenshot('filename')` locally and it does work, but when I use it in my pipeline it does not save the file. I am just trying to debug and fully understand why is it failing – Nayden Van Aug 27 '21 at 09:19
  • If the question is answered elsewhere on Stack Overflow, the question is a duplicate and you should vote to close as a duplicate, not post an answer. – Daniel Mann Aug 28 '21 at 15:32