Selenium Webdriver script to get data from textbox and clear the data


package selenium_examples;


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class Test {

public static void main(String[] args) {


WebDriver driver = new FirefoxDriver();
driver.get("http://google.com");

driver.findElement(By.id("gbqfq")).sendKeys("Selenium");

System.out.println(driver.findElement(By.id("gbqfq")).getAttribute("value"));

driver.findElement(By.id("gbqfq")).clear();
 
}
}

Output will be:-

Selenium


Above script opens google site and enters Selenium in search textbox and then captures data from the textbox and prints 'Selenium' in Console.
The clear() method deletes the text in text box.




No comments:

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge