0% found this document useful (0 votes)
40 views

Setup Selenium With Java For Test Automation

Selenium can also be integrated with Java, here are some instructions on how to run from the command-line, IDE, or via a CI build tool.

Uploaded by

BCmoney
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Setup Selenium With Java For Test Automation

Selenium can also be integrated with Java, here are some instructions on how to run from the command-line, IDE, or via a CI build tool.

Uploaded by

BCmoney
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Setup Selenium with Java for Test Automation

1. Download the following:


a. NetBeans IDE

b. Selenium Server from http://seleniumhq.org/download/

c. Selenium Java Client from http://seleniumhq.org/download/

d. Install Selenium IDE from http://seleniumhq.org/download/

2. Install NetBeans IDE (using 7.1 as example).


3. Extract both 1b and 1c to your local drive.

4. Create New Project in NetBeans:

5. Enter Project Name as <whatever name you like>

6. Click on Finish.

7. Right click Libraries and Select Add JAR/Folder

8. Add the downloaded and extracted JARs to the project:

9. It will look like this now:

10.Right click Source Packages and create new Java Class

11.Enter <whatever name> into Class Name field and click Finish.

12.Type in the following code:

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

You might also like