tejas
tejas

Reputation: 67

SetAttribute value for html tag

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

Answers (2)

Hary
Hary

Reputation: 5818

The most simplest way to assign value to span is

document.getElementsByTagName("span")[0].innerHTML = "70%";

Upvotes: 0

T.J. Crowder
T.J. Crowder

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

Related Questions