Hey Komal, to get the text of a web element in Selenium Webdriver you can use getText() method:
package getTextPackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class getTextTest {
@Test
public void testmethod(){
System.setProperty("webdriver.chrome.driver", "C:\\Downloads\\Drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
String availableText = driver.findElement(By.xpath("//*[@id='gbw']/div/div/div[1]/div[1]/a")).getText();
System.out.println("Text Available is :"+availableText);
}
}