user170732 user170732 - 3 months ago 24
Python Question

Waiting for a button state to change in Selenium Webdriver

I am testing a textbox and button - the user types in some information to the textbox and then hits the button - the button changes text from "Update" to "Updating" and then back to "Update" once the operation is complete.

I want Selenium to wait until the button returns back to "Update" before continuing.

I have tried various solutions using xpath here is where I am now:

self.wait.until(EC.element_to_be_clickable(By.XPATH, '//button[@id="send_data"][text()="Update"]'))

The HTML of the button is as follows:

<button id="send_data" type="button" class="btn btn-success" onclick="ChangeParam(this,'radio','freq'; return false;">Update</button>


<button id="send_data" type="button" class="btn btn-default" onclick="ChangeParam(this,'radio','freq'; return false;">Updating</button>

Where am I going wrong?


This is quite common issue: you should send type_of_locator, "locator_string" as tuple of arguments ((By.XPATH, "//button")), but not as two separate args (By.XPATH, "//button")

Use following code