in Selenium by
Q:
How to get an attribute value using Selenium WebDriver?

1 Answer

0 votes
by
By using getAttribute(value);

It returns the value of the attribute passed as a parameter.

HTML:

<input name="nameSelenium" value="valueSelenium">SoftwareTestingMaterial</input>

1

<input name="nameSelenium" value="valueSelenium">SoftwareTestingMaterial</input>

Selenium Code:

String attributeValue = driver.findElement(By.name("nameSelenium")).getAttribute("value");

System.out.println("Available attribute value is :"+attributeValue);

Output: valueSelenium

1

2

3

String attributeValue = driver.findElement(By.name("nameSelenium")).getAttribute("value");

System.out.println("Available attribute value is :"+attributeValue);

Output: valueSelenium

Related questions

0 votes
asked Aug 22, 2019 in Selenium by john ganales
0 votes
asked Aug 22, 2019 in Selenium by john ganales
...