ATTRIBUTE VALUE

 

      We can use driver.findElement() to find element and user the method get attribute() and pass the attribute name as an argument which will return the value of the attribute.

 

package mypackage;

 

import java.util.concurrent.TimeUnit;

 

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

 

public class TitleCheckPoint {

 

public static void main(String[] args) {

System.setProperty("webdriver.gecko.driver","C:\\Browser\\geckodriver.exe");

WebDriver driver=new FirefoxDriver();

driver.manage().window().maximize();

driver.get("https://demo.actitime.com/login.do");

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

 

String attribute=driver.findElement(By.id("username")).getAttribute("class");

System.out.println(attribute);

}

}