Pierre Capon
Pierre Capon

Reputation: 143

How can I change/remove style attibute with selenium python?

I was wondering if it was possible to change or remove the "display: none;" in the element to make it visible with selenium in python.

<textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid #c1c1c1; margin: 10px 25px; padding: 0px; resize: none;  display: none; "></textarea>

I already tried this:

driver.execute_script("document.getElementById('g-recaptcha-response').style.display = '1';")

but apparently it does not work.

Any help would be apprreciated. :)

Upvotes: 2

Views: 3713

Answers (1)

Pierre Capon
Pierre Capon

Reputation: 143

It was just the wrong CSS attribute, this works

driver.execute_script("document.getElementById('g-recaptcha-response').style.display = 'block';")

Thanks to @Andersson

Upvotes: 1

Related Questions