0

when I execute

wait = WebDriverWait(driver, 20)  # Adjust the timeout value as needed
parent_div = wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, ".el-table-box")))
print(parent_div)

I get

[<selenium.webdriver.remote.webelement.WebElement (session="136cf2ec383dc1418886e107a4041971", element="5033E27DBF4D61FD1E1C653BCA654DF5_element_8")>]

Is parent_div a list object? How can I print its entire content?

Steven
  • 24,410
  • 42
  • 108
  • 130

1 Answers1

0

visibility_of_all_elements_located()

visibility_of_all_elements_located() is the expectation for checking that all elements are present on the DOM of a page and visible. A locator is used to find the elements which returns the list of WebElements once they are located and visible.

Accordingly parent_div contains a list of WebElements which prints:

[<selenium.webdriver.remote.webelement.WebElement (session="136cf2ec383dc1418886e107a4041971", element="5033E27DBF4D61FD1E1C653BCA654DF5_element_8")>]

This usecase

To print the value of any of the attributes you need to use the get_attribute(attributename) method and using list comprehension you can use the following solution:

print([my_elem.get_attribute("attributename") for my_elem in driver.find_elements(By.CSS_SELECTOR, ".el-table-box")])
  
  • Note : You have to add the following imports :

    from selenium.webdriver.common.by import By
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352