Note: use getAttribute("textContent") method to get the hidden text.
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Facebook {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.get("https://www.facebook.com/");
String value= driver.findElement(By.xpath("//a[@title='Go to Facebook Home']")).getAttribute("textContent");
System.out.println("Value is : " + value);
boolean box= driver.findElement(By.xpath("//input[@type='checkbox']")).isEnabled();
System.out.println(box);
driver.close();
}
}
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Facebook {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.get("https://www.facebook.com/");
String value= driver.findElement(By.xpath("//a[@title='Go to Facebook Home']")).getAttribute("textContent");
System.out.println("Value is : " + value);
boolean box= driver.findElement(By.xpath("//input[@type='checkbox']")).isEnabled();
System.out.println(box);
driver.close();
}
}
Hi dude, I unable to understand 1 statement.
ReplyDeleteString value= driver.findElement(By.xpath("//a[@title='Go to Facebook Home']")).getAttribute("textContent");
In this statement, where you got this string "textContent". In web I have not found it.