Setup Selenium With Java For Test Automation
Setup Selenium With Java For Test Automation
6. Click on Finish.
11.Enter <whatever name> into Class Name field and click Finish.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile.*;
public class MyFirstAutomation {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com.my");
driver.manage().window().maximize();
WebElement queryBox = driver.findElement(By.id("gbqfq"));
queryBox.sendKeys("My Very First Automation");
driver.findElement(By.id("gbqfb")).click();
}
}
13.Click Run (then click OK if applicable):
14.At this point, you should be able to see that the program opens up a
FireFox browser, maximizes the window, navigate to google, then search
for the term My Very First Automation. Congratulations! Your setup is
complete!
Disclaimer: This document is for educational and personal use only. Do not
distribute it for commercial purposes. Although every reasonable effort is
made to present current and accurate information, no guarantee will be
given.
Regards,
Fong Kai The testing guy @QAKL