We are already finished with the prerequisite for starting with “Selenium”.Now we are taking a step further towards learning “Selenium”.
You can also check how to write first program in Eclipse.
Requirement:-Configuring Selenium Webdriver Jar files in Eclipse to write our first Selenium Program.
Solution:-
Step1:-Adding Jar files to Eclipse
Right Click “Java Project” in Package Explorer ->Build Path ->Configure Build Path
You can also check how to write first program in Eclipse.
Requirement:-Configuring Selenium Webdriver Jar files in Eclipse to write our first Selenium Program.
Solution:-
Step1:-Adding Jar files to Eclipse
Right Click “Java Project” in Package Explorer ->Build Path ->Configure Build Path
![]() |
Configure Build Path |
Select Libraries Tab ->Click Add External JAR’s
![]() |
Add External JAR’s |
Browse to Selenium JAR files (For DownloadProcess) ->Add the Selenium JAR (We can add source JAR also) , Open the Lib folder to add all the JAR files.
![]() |
Browse the Selenium JAR location |
Click OK button to Add all the selected JAR files
![]() |
Adding JAR to Project |
Note :- One’s JAR files are added, we can confirm it, under Reference in Project Explorer
Step2:- Writing and Running our first line of Selenium Code.(For running the First Java Program)
Flow :- Launching the firefox browser -> open the URL -> fetch the Title details.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class LearnSelenium {
public static void main(String[] args) {
//Creating WebDriver Object
System.out.println("Launching the Browser");
WebDriver driver = new FirefoxDriver();
//Opens the given URL
driver.get("http://www.uftHelp.com");
System.out.println("Fetching the Title");
System.out.println("Please Wait!!");
//Returns the Title of Current Page
String sTitle = driver.getTitle();
System.out.println("My First Selenium Program");
System.out.println("Title is = '"+sTitle+"'" );
//Closing the Browser
driver.close();
}
}
Add the above lines of code and Run it to success (CTRL + F11)
Result in Console
![]() |
Console Results |
3 replies on “How to write my first Test Case using Selenium in Eclipse?”
driver.get()//From where this methods is coming.Can anyone explain me the back end process.
driver.get() method is coming from the FirefoxDriver class
driver.get() method is coming from the FirefoxDriver class