Sunday, December 31, 2017

WebDriver Launch Browser Open Website Find the Element Send the text and click on Button

WebDriver Launch Browser Open Website Find the Element Send the text and click on Button



How to launch browser, open the website and send text on find input element then click on button through Selenium Web Driver


Steps:
  •  Create Driver for Browser open
  • Open the URL
  • Find the element on webpage and assign on Web Element variable
  • Send text on above find out element on webpage
  • Click on find out element on webpage
  • Close the Browser
  • Quit the selenium

Selenium Code:



package Selenium_WebDriver;

importorg.openqa.selenium.By;

importorg.openqa.selenium.WebDriver;

importorg.openqa.selenium.WebElement;

importorg.openqa.selenium.firefox.FirefoxDriver;


public classLaunchBrowser_SendText_ClickButton {


       public static void main(String[] args) {

              //Define Firefox Browser and open the Firefox Browser

                           WebDriver driver = new FirefoxDriver();

                          

                           //Open the URL (Website)

                           driver.get("http://google.co.in");

                          

                           //Find the element on webpage and assign on Web Element variable

                           WebElement search = driver.findElement(By.id("gbqfq"));

                          

                           // Send text on above find out element on webpage

                           search.sendKeys("Selenium");

                          

                           // Click on find out element on webpage

                           search.submit();

                          

                           //Close the Broswer

                         driver.close();

                            

                         // Quit the selenium

                         driver.quit();

                          

       }

}




go to link download

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.