V
V
vlarkanov2020-08-18 14:14:14
Python
vlarkanov, 2020-08-18 14:14:14

How to correctly execute a js query querySelector in Selenium (Python)?

There is a query pointing to the desired page element:

document.querySelector('form table tr:first-child td:nth-child(2) b')

How to execute this query from python selenium and get the string contained in the given element?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2020-08-18
@vlarkanov

element =  driver.execute_script("return document.querySelector('form table tr:first-child td:nth-child(2) b')")
value = element.text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question