Waiting for text change in Selenium elements: A comprehensive guide

One of my elements changes its status in text form based on a context menu that is associated with it.
Here is the particular element:

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

Under certain circumstances, this can transform into

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

I am looking to delay execution until the text change occurs, using waitForCondition method.
I have attempted the following so far:

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

However, this approach does not work as the text is not included within the td element.
In JavaScript, I have come across something like:

function myfunc() {        
window.getGlobal().addSelectGroup('status'); window.getGlobal().addSelectItem('status','StatusStart'); 

Answer №1

Consider updating the xpath in the following way.

//td[@title='status' and .//text()='StatusCompleted']

or

//td[@title='status' and contains(.//text(),'StatusCompleted')]

Answer №2

It appears that there is a misunderstanding regarding whether the text is part of the td element. The HTML code provided indicates that the text should indeed be within the TD element. The function waitForCondition() seems to be the correct approach, so the issue might lie in the exact text being different from what was expected - perhaps due to extra spaces. To resolve this, consider adjusting the comparison to include the necessary spaces or using contains(text(), 'StatusDone') as an alternative.

Answer №3

To achieve this, you may want to incorporate a continuous

storeText(css=td[name=status],var_name)
in a do-while loop (java) and terminate the loop when var_name="StatusDone"

Answer №4

Do you know what an implicit wait is?

To implement an implicit wait in Selenium, use the following command: driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Execute a Selenium WebDriver test on a server running the Linux operating system

I am attempting to execute a test using selenium webdriver on a Linux server with Chrome and no display. Below is my Java code: System.setProperty("webdriver.chrome.driver","/home/exploit/Bureau/chromedriver"); WebDriver driver = new ChromeDriver(); dri ...

Vue components: Using `object[key]` as a prop does not trigger reactivity

I'm attempting to bind a value from an Object into the prop of a Component, but unfortunately it is not reacting as expected. Despite using $this.set, the reactivity issue persists. Below is my template: <div class="grid"> <emoji-card v-fo ...

Rule: attribute should indicate a specific function

I am currently trying to implement the functionality from https://github.com/rpocklin/angular-scroll-animate in my project, but I keep encountering an error in my console: Error: Directive: angular-scroll-animate 'when-visible' attribute must ...

Using ES6 classes in Express routes: It is not possible to create the property 'next' on the string '/'

I'm currently working on integrating routes using classes in my express js application controller class User { constructor (){ this.username = 'me'; } getUsername(req,res){ res.json({ 'name& ...

I Am unable to locate the '...' after applying the text-ellipsis style to a div

https://i.stack.imgur.com/Tsmf5.png The ellipsis '...' is not showing up even after I have applied text-ellipsis, overflow hidden, and nowrap to this div. Take a look at my code: import Image from "next/future/image"; import Link from ...

transferring data from grails to javascript via a map

I am facing an issue with passing a Map object from my Grails controller to JavaScript. The code snippet in my controller is as follows: def scoreValue = new HashMap<String,String>(); scoreValue.put("0","poor"); scoreValue.put("1","good"); ... retu ...

What is the best way to show the associated ul tag?

I've constructed the following HTML: <input id="<code generated id>" type="text" value="select"/> <div id="<code generated id>" class="popup"> <ul id="<code generated id>" class="none"> <li>A</li& ...

When loading a page for the first time, the Vue.js transition does not take effect

After setting up a navbar that switches between two components, I encountered an issue with the fade-in animation not running when the page is first opened. The animation only works when using the navbar links to switch components. Any suggestions on how t ...

ReactJs: How useEffect is invoked before onClick function in NextJS

I am facing an issue with a button in my Next project. Here is the code for the button: <Button minWidth={'140px'} onClick={() => exec(scope)} >Save</Button> When this button is clicked, it triggers the following function: c ...

Aurelia's numerous applications spread across various pages

Currently, I am in the process of finalizing the initial release of a large-scale website built using PHP (Phalcon), MySQL, and JQuery. The technology stack may be a bit outdated, but it was originally prototyped years ago and due to various circumstances, ...

How can I integrate Apple remote support into a website with the use of Javascript?

One thing that I find interesting is the ability to use the Apple remote with Front Row, as well as other apps on Mac that support it. I'm curious about whether Web Apps could also be made compatible through Javascript. I have a concept for a TV-like ...

Silent response upon click event listener

I'm having an issue with a navbar item not calling the reverseService function on click as expected. Although my IDE is indicating that the reverseService function is never used, VueJS dev tool doesn't show any problems. However, manually changi ...

Leverage jQuery deferred objects to handle a dynamic amount of AJAX requests

When faced with multiple ajax requests, how can I execute them using deferreds? This is my approach: //qty_of_gets = 3; function getHTML(productID, qty_of_gets){ var dfd = $.Deferred(), i = 0, c = 0; // hypothetical cod ...

Conditionally submit a form using JQuery

I need to implement a validation condition using jQuery for a form submit button. The requirement is that the form should only be submitted if the user enters a valid email address. HTML code : <form method="post" action="{% url sportdub.views.login ...

Having trouble dealing with certificate OS pop-ups in Selenium using Python? I attempted to use pyAutoGUI, but unfortunately, it was not successful

Working with Selenium in Python to navigate on Google Chrome has been a smooth process until an SSL certificate popup appeared. Despite having a valid certificate and simply needing to press 'Ok', it seems that this particular popup is not browse ...

Issue uploading with Candy Machine Version 2/ complications with directory

For some reason, I am encountering issues with the upload operation. Switching from relative to absolute paths did not resolve the error, and using the -c flag for the directory containing images and JSON files is causing a problem. However, other flags ...

The PDF structure in vue3-pdf is not valid and may cause errors

This error is occurring on almost every file, except for one that works fine. The console also displays the following warning: Warning: Indexing all PDF objects. Object { message: "Invalid PDF structure.", name: "InvalidPDFException", ...

What is the process for converting a multidimensional array from PHP into JavaScript?

Recently, I've been experimenting with dygraph. To populate my graph, I fetch data via an ajax call and then need to convert the returned JSON array into a JavaScript array. My dygraph options are set up like this: series = { sample1: { ...

Retrieving a numerical value from a constantly changing string

The string is constantly changing. For example: Date15:Month8:Year1990 Is there a way to extract the number 15 without using substring, since the values are always different? I am looking to extract only the number after "Date" and before ":". ...

Angular does not assign the ng-invalid-class to the input

In order to register custom validation methods for custom form elements, we use extra directives as shown below: <ng-form name="validatorTestForm"> <our-input-directive name="validatorTest" ng-model="ourModel"/> ...