1

I have a span element like this

<span id="yui-gen56" class="ir i-doc" style="background-color: transparent;"></span>

Now I want to retrieve the class attribute value so that it should return me ir i-doc for verification. Any idea how can I get this attribute value for further verification.

Thanks in advance

2 Answers 2

5

You can try something like below where driver is object of WebDriver -

WebElement webElement = driver.findElement(By.id("yui-gen56"));
webElement.getAttribute("class");
Sign up to request clarification or add additional context in comments.

1 Comment

Simple and ultimate working solution, thanks Bhushan!! Cheers!!
1

Try this...

WebElement cssValue = driver.findelement(By.cssSelector("[id='yui-gen56'][class='ir i-doc']"));
String Value = divElement.getText();
System.out.println(Value);

It helped me in finding value of css class..

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.