1

I have the element

<p id="LIST_VAR2">3</p>

What I'd like to do is change the 3 to a 10. Is there anyway to do this with Selenium?

1
  • You really don't want to do this. No user is going to be able to access the page in this way and this is only temporary, if you refresh the page any changes will be lost. How would a user change this value? Automate that. Commented Dec 17, 2016 at 16:11

1 Answer 1

2

I don't know of a pure Python way, but you can use Selenium to run some Javascript!

driver.execute_script('document.getElementById("LIST_VAR2").textContent="10";')

This Javascript finds the element using the ID with getElementbyId and changes the textContent.

Note that I use single quotes to surround the Javascript and double quotes inside the Javascript. This is so Python doesn't interpret the string as ending whenever it sees the double quote. As long as you use double quotes inside the JS and single quotes to surround it (or vice-versa), you'll be fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.