Selenium: how to getAttribute with Selenium WebDriver

Last updated on:

Sometimes you would want to assert that attribute was not changed or corrupted, here is how you would do it:

WebElement DownloadURL = driver.findElement(By.link_text("Download URL"))
String urlToCompare = DownloadURL.getAttribute("href").toString();

Assert.assertEquals("URL_To_Compare", urlToCompare);
View Comments

Leave a Comment

Use markdown or basic HTML and be nice.