Selenium: how to wait for an element to change text

I have an element whose status (in text form) changes depending on the context menu associated with it.
Here is the item:

td id="A" name="status"> StatusStart </td> 

With some actions, this may become

  td id="A" name="status"> StatusDone </td> 

I want to wait for the text to change using waitForCondition.
So far I have tried:

 selenium.waitForCondition("selenium.isElementPresent(\"//td[@name='status' and text()='StatusDone']\");", "10000"); 

but this does not work because the text is not part of the td element.
In JavaScript, I see something like:

 function myfunc() { window.getGlobal().addSelectGroup('status'); window.getGlobal().addSelectItem('status','StatusStart'); 
+4
source share
4 answers

You can implement repeating storeText(css=td[name=status],var_name) in a do-while ( java ) loop and break once var_name="StatusDone"

0
source

Try changing xpath as follows.

 //td[@name='status' and .//text()='StatusDone'] 

or

 //td[@name='status' and contains(.//text(),'StatusDone')] 
+4
source

You say: "this does not work because the text is not part of the td element." Which is strange because the displayed HTML says that the text is part of the TD element. And the waitForCondition() you tried is exactly how to do this. My best guess is that the TD text is not exactly “StatusDone”, but rather “StatusDone” (based on your HTML). Comparison will never match, if so. There are obvious ways to fix this: add spaces to the constant or use contains(text(), 'StatusDone') instead of comparing.

+1
source

Implicit wait?

 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 
0
source

All Articles