Interview Questions

Selenium WebDriver - How do you get the attribute of the web element ?

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

Selenium WebDriver - How do you get the attribute of the web element ?

driver.getElement(By.tagName(“img”)).getAttribute(“src”) will give you the src attribute of this tag. Similarly, you can get the values of attributes such as title, alt etc.
Similarly you can get CSS properties of any tag by using getCssValue(“some propety name”).

(Continued on next question...)

Other Interview Questions