0

I am try to change non input attribute value in Firefox frame in the format:

 <div id='100' class='abc'>
<p> hello </p>
</div>
<div id='200' class='abc'>
<p> hello 2 </p>
</div>
.....

I want to change hello 2 to welcome I try this code but it does not work

driver.execute_script("document.getElementsByClassName('abc')[0].text='welcome';");
João Farias
11.2k2 gold badges21 silver badges41 bronze badges
asked Jun 14, 2019 at 21:58

1 Answer 1

0

Your locator would fetch the first div, of id = 100.

Try the following:

document.querySelector('#200 p').innerText='welcome';
answered Jun 15, 2019 at 9:02
2
  • what if I want to use class name 'abc'?? Commented Jun 15, 2019 at 11:46
  • document.querySelector(".abc p") Commented Jun 3, 2021 at 14:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.