Skip to main content

Script to open the browser using Selenium Web Driver

To open the Firefox browser by using selenium Web driver, we need to follow following procedure

Step 1: First You need to create a Java Project

Open the eclipse > Click on File  > Click on New > Click on Project
Selenium Web Driver, Automation Testing, Open Browser Script

Then select Java Project and then click on next Button
Selenium Web Driver, Automation Testing, Open Browser Script
Then right the project name and click on Next button then click on Finish Button
Selenium Web Driver, Automation Testing, Open Browser Script
Step 2: Now You need to create the package
for create the Package, First click on the newly created Project
Then Right Click on src folder > Click on New > Click on Package
Selenium Web Driver, Automation Testing, Open Browser Script, Select Package

Then Type the package name and click on Finish Button
Selenium Web Driver, Automation Testing, Open Browser Script, Package Name
Step 3: Now We need to create Class
Right Click on newly created package > click on New -> click on Class
Selenium Web Driver, Automation Testing, Open Browser Script, Create Class


Now Type the name of class and click on Finish button
Selenium Web Driver, Automation Testing, Open Browser Script, Class Name
We found following code in our page

                         package testPackage;
                         public class TestClass{
                         }

Step 4: Now in class we need to define the main method because every java project need main method to execute the code.

                           public static void main(String[] args)

Step 5: Now we will write script to open the Firefox browser

                      WebDriver driver = new FirefoxDriver();

here WebDriver is the Interface
driver is the reference Variable Name
new is the keyword
FirefoxDriver() is the constructor of the Firefox driver class

Let me explain the code.
instance of the FirefoxDriver class has been created and the address is stored in the interface WebDriver type driver object.

This will open a Firefox brower in your system.
To put any URL in the browser you can write following line

    driver.get("URL");

So to open a browser and run aURL

    package testPackage;
   
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
   
    public class TestClass{
        public static void main(String[] args) {
   
        WebDriver driver = new FirefoxDriver();
        driver.get("https://www.google.co.in");
        }
    }




Comments

Popular posts from this blog

What is API?

In general way, API (Application Programming Interface) is the intermediate software which is useful for two applications to communicate. API is the tool which is used for interaction of two applications. If developer developing any software which have multiple blocks (Modules) than developer use APIs to put them together.

Ad-Hoc Testing

Ad-Hoc Testing is the testing type which is performed without any proper procedure and without any Requirement Specification. Ad-Hoc testing is totally informal testing which have intension to break the application as early as possible and found important defect early.  In Ad-hoc testing tester do not have any test cases so only the users who have very high knowledge regarding the application only they can perform Ad-Hoc Testing.

Smoke Testing

In Smoke Testing, Testing team check the key feature or key bugs of the software. Smoke testing ensure that critical functionality of the software is working fine.If key features are not working then it is no needed to test the overall functionality because it is just waste of time. In Smoke Testing, test team check the basic feature of the software and if basic feature is not working it means software is broken very badly and further testing is unnecessary. If Smoke Testing failed then it is declared that build is unstable and revert back to developer team until smoke test is pass.