SonOfGritty
SonOfGritty

Reputation: 1

Python Selenium - Attempting to write wait condition for when text changes in table element

I am attempting to write a selenium script to search for terms on a webpage, then select them from a table.

The table is dynamic and changes when elements are entered into the search field. Typically when I have written selenium code in the past, I have just used wait statements to wait for some element on the page to load before continuing. With this, I specifically need to wait until the element I am looking for to appear in the table, and then to select it.

Here is what I currently have written, where tableElement is the table I attempting to search through, and userID is the input I am hoping to find:

tableElement = self.driver.find_element_by_xpath(
                'X-PATH_TO_ELEMENT')

ui.WebDriverWait(self.driver, 15).until(
                EC.text_to_be_present_in_element(
                    tableElement, userID)
            )

When running this code, I receive the following error message:

find_element() argument after * must be an iterable, not WebElement

As far as I am aware, this should be the correct syntax for the method I am attempting to call. Any help would be appreciated! Please let me know if I need to elaborate on any details.

Upvotes: 0

Views: 158

Answers (1)

SeleniumUser
SeleniumUser

Reputation: 4177

Expcted condition are basically used with find_element and find_elements.

In your code you have provided web element to EC instead of locator.

you can use below code to use EC in your code :

WebDriverWait(driver, 30).until(
             EC.visibility_of_all_elements_located((By.XPATH, "xpath of your element")))

Note: you have to add below importss to your solution:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

Upvotes: 1

Related Questions