Reputation: 67
I want to set attribute value for below html tag using selenium webdrive. Say for ex... I want to replace 50% to 70% using either JavaScript with Webdriver or Simple webDriver Script.
I try many options but this tag does not have attribute except only class. So Please help me
<Span class="abc">50%</span>
Upvotes: 1
Views: 267
Reputation: 5818
The most simplest way to assign value to span
is
document.getElementsByTagName("span")[0].innerHTML = "70%";
Upvotes: 0
Reputation: 1074385
That's not an attribute value, that's content. So you'll want the Selenium optionfor setting content rather than attributes.
You mention JavaScript. You can set the content of a span
in JavaScript by getting a reference to the span
element and setting its innerHTML
property (or accessing the Text
node it contains and setting its nodeValue
property).
Upvotes: 3