It is a dynamic span. I want to get the number that keeps changing. In this case it would be 436
Code trials:
valorliquido = navegador.find_element_by_css_selector("span[class="woocommerce-summary__item-value"]")
Got:
valorliquido = navegador.find_element_by_css_selector("span[class="woocommerce-summary__item-value"]")
^
SyntaxError: invalid syntax
Snapshot of the HTML:
2
Answers
You have used double-quotes to wrap the class name of the CSS selector and also to wrap the whole selector string. This causes a syntax error because the interpreter is not able to distinguish between the two sets of double-quotes.
You can fix this by using single quotes
Or escaping the double quotes so they have no effect
You have to take care of a couple of things:
If you pass the locator value within double quotes i.e.
"..."
you have to use the single quotes for the attribute values as'...'
With selenium4 find_element_by_* commands are deprecated and you have to use the following syntax:
Solution
Youe effective line of code will be:
To print the text 436: