Wait for element to be displayed/visible Timeout issue...

125 views
Skip to first unread message

mawa316

unread,
May 3, 2018, 10:41:52 AM5/3/18
to Selenium Users
Hi all,

I'm back with another wait involved question.  I have a test record displayed in a grid and I check some things on this record to make sure 'stuff' is working properly...

               

string docTitle = "ASH REF DWG";

         

// Check the status...


                logger.Debug("Checking file status...");


                //driver.FindElementByXPath("//div[contains(text(), 'New')]");


                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("//div[contains(text(), 'New')]")));



                // Check the version


                logger.Debug("Checking file version...");


                //driver.FindElementByXPath("//div[contains(text(), '0.1')]");


                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("//div[contains(text(), '0.1')]")));



                logger.Debug("New document present with correct status/version! Checking extracted data...");



                // Check extracted data...


                Thread.Sleep(5000); // Repeated failures here.  Neither wait type passes during nightly test but OK during manual run of test.              


                wait.Until(d => driver.FindElementByXPath("//div[contains(text(), '" + docTitle + "')]").Displayed);


                //wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("//div[contains(text(), '" + docTitle + "')]")));


                logger.Debug("File attribute extracted successfully!");


The displayed record looks like this...


First and second checks for "New" and "0.1" pass through fine, but the check for "ASH REF DWG" (docTitle) fails with Exception: Timed out after 30 seconds.  I have tried both wait types as shown below and even added a Sleep against my better judgment to see if that would help.

At first I thought that maybe it is because that column is not fully expanded and the full text is not displayed.  However, when I inspect the element, it does contain the required text.

All of the above information pertains to when our tests run unattended at night.  The test has failed in the same spot for the last four days and each morning following failure I am able to run the test as is, without issue from Visual Studio.

Does anyone know what the issue might be or how to really pin down or catch what is going on?
Auto Generated Inline Image 1

Ankit Gupta

unread,
May 4, 2018, 12:18:51 AM5/4/18
to seleniu...@googlegroups.com
Implement explicit wait and use the condition PresenceOfElement

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/8fa2e267-1226-4463-916c-320011a0ee62%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jonathan Herbaut

unread,
May 4, 2018, 3:10:30 AM5/4/18
to seleniu...@googlegroups.com
I'm not sure the PresenceOfElement will change a lot for this, ElementIsVisible is almost the same for this case because the element is shown.
When you want to check ASH REF DWG, be carefull because with your screenshot it seems like you have ellipsis in your UI, and no direct test can compare a troncated text with your full text.
If your loop works with "New" and "0.1", that's not your XPath that is wrong but your comparison in the wait.

To post to this group, send email to seleniu...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

mawa316

unread,
May 6, 2018, 7:33:17 AM5/6/18
to seleniu...@googlegroups.com
I will try the explicit wait + PresenceOfElement.

Does the wait search for the text displayed when I inspect the element, which is the full string mentioned or string displayed with the ellipsis.


--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/JYTJCovWZgg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-users+unsubscribe@googlegroups.com.

To post to this group, send email to selenium-users@googlegroups.com.

mawa316

unread,
May 11, 2018, 10:49:19 AM5/11/18
to seleniu...@googlegroups.com
So, I let the test run for several days and it consistently still fails in the same spot after ...

logger.Debug("New document present with correct status/version! Checking extracted data...");

The Thread.Sleep has been removed and I've swapped between these two, as shown above...

//wait.Until(d => driver.FindElementByXPath("//div[contains(text(), '" + docTitle + "')]").Displayed);

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("//div[contains(text(), '" + docTitle + "')]")));

docTitle is now ARD1

The exception I receive now is - Timed out after 30 seconds.  What should this be telling me?

I am completely baffled at this point.  I have had problem areas in tests before, but I was usually able to work through them with a small tweak of some sort.  This problem will just not go away.


Reply all
Reply to author
Forward
0 new messages