Automation Script Implementation in Webdriver
Quality,  Selenium,  Software Testing,  Webdriver

Automation Script Implementation in Webdriver

Automation Script Implementation in Webdriver:

Let’s know, how to do Automation Script Implementation in Webdriver in Eclipse by using Java. Here in this article, I have implemented a Selenium Webdriver automation script of Practice form to fill for the purpose of Practice for Automation Testing.

In this script, I have taken Project Name: Selenium Automation, Package name: Practice, Classname: Webdriver_Practice

In this script I have used to automate Text boxes, dropdown, Multiple options select in List box, Button, Radio button, Checkbox, Image path for upload, parameterization, Google chrome browser launch etc.

 

package Practice.Practice;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.support.ui.Select;

 

public class Webdriver_Practice {               

                public WebDriver driver;

          

                public void Chrome_Launch() {

                           System.setProperty(“webdriver.chrome.driver”, “D:\\Selenium\\Library\\chromedriver.exe”);

                           driver=new ChromeDriver();

                }

               

                public void Url_0pen() {

                               driver.manage().window().maximize();

                                driver.get(“http://toolsqa.com/automation-practice-form/”);

                }

               

              public void Practice_Automation_Form(){

 driver.findElement(By.partialLinkText(“Partial Link Test”)).click();  //click on Partial Link Test                                                               driver.findElement(By.xpath(“/html/body/div[1]/div[5]/div[2]/div/div/div[1]/div/div/div/div[2] /div/form/fieldset/div[8]/input”)).sendKeys(“Test”);  //Enter First Name

 driver.findElement(By.xpath(“/html/body/div[1]/div[5]/div[2]/div/div/div[1]/div/div/div/div[2] /div/form/fieldset/div[11]/input”)).sendKeys(“Name1”);   //Enter Last Name

 driver.findElement(By.id(“sex-0”)).click();  // Select the Sex as Male

 driver.findElement(By.id(“exp-3”)).click();  // Select the Years of Experience

 driver.findElement(By.id(“profession-0”)).click(); // click on check box of Profession as Manual Tester

 driver.findElement(By.id(“profession-1”)).click(); // click on check box of Profession as Automation Tester

 driver.findElement(By.id(“photo”)).sendKeys(“C:\\Users\\Public\\Pictures\\Sample Pictures\\test.jpg”); // This line of code will upload the Profile pic from the Local system drive

 new Select(driver.findElement(By.id(“continents”))).selectByVisibleText(“Australia”); // This line of code is for Select the value from a dropdown field.                     

 }

 /*This below method is to select multiple options in a Listbox or dropdown  */        

  public void Select_Multiple_Options_In_Listbox(){

                               WebElement Groupid_select=driver.findElement(By.id(“selenium_commands”));

                                Select group=new Select(Groupid_select);

                                group.selectByVisibleText(“Browser Commands”);

                                group.selectByVisibleText(“Navigation Commands”);

                                group.selectByVisibleText(“Wait Commands”);

                   }

               

                public void Submit_Form(){

                                driver.findElement(By.id(“submit”)).click();  // click on the Submit button

                                driver.close();

                               }

 

                public static void main(String[] args) {

                                // TODO Auto-generated method stub

                               Webdriver_Practice d=new Webdriver_Practice();

                                d.Chrome_Launch();

                                d.Url_0pen();

                                d.Practice_Automation_Form();

                                d.Select_Multiple_Options_In_Listbox();

                                d.Submit_Form();         

                }

}

 

Please click here to Read Browser Launch in Selenium Webdriver

Please click here to Read X-path through Firebug and FirePath

3 Comments

  • Hairstyles

    I have observed that in the world of today, video games are classified as the latest rage with children of all ages. There are occassions when it may be impossible to drag your children away from the games. If you want the best of both worlds, there are several educational video games for kids. Thanks for your post.

  • Hairstyles

    My spouse and I absolutely love your blog and find most of your post’s to be just what I’m looking for. Do you offer guest writers to write content for yourself? I wouldn’t mind creating a post or elaborating on a few of the subjects you write regarding here. Again, awesome blog!

  • Hairstyles

    Can I just say what a reduction to find somebody who really is aware of what theyre speaking about on the internet. You definitely know learn how to bring a difficulty to light and make it important. Extra folks must learn this and perceive this side of the story. I cant believe youre no more fashionable since you definitely have the gift.

Leave a Reply

Your email address will not be published. Required fields are marked *