sukgu / pyshadow

Selenium plugin to manage multi level shadow DOM elements on web page.
Apache License 2.0
47 stars 10 forks source link

how can i get all elements that match criteria? #15

Closed andresgd7 closed 1 year ago

andresgd7 commented 1 year ago

Im trying to get all the rows of a table, but when i use the find_elements method it just return the first coincidence, i'm missing something?

davieduardo94 commented 1 year ago

Dependent of the context, if you using xpath, you might need to use up element to select all below.

Can you post a example here?

andresgd7 commented 1 year ago

Hi david, thanks for answering. Im trying to get a boton wich is inside of a table. Im looking for the button by this way:

from pyshadow.main import Shadow
shadow = Shadow(driver)

shadow.find_elements('siigo-button-atom[class="hydrated"]')

This return me the first element but not all the elements with this properties as a list, im missing something?

andresgd7 commented 1 year ago

An update. By the moment, i get the descendant elements using selenium and scripting. I was looking for an input field.

shadow_root = driver.execute_script("return arguments[0].shadowRoot", driver.find_element(By.CSS_SELECTOR, "HERE>GOES>PARENT>SHADOW>CSS_SELECTOR"))

shadow_root.find_element(By.CSS_SELECTOR, "HERE>GOES>DESCENDANT>SHADOW>CSS_SELECTOR")).send_keys("Cualquier chimbada que vayan a mandar")

i hope this helps someone in the future.