Blog

  • How to Open Chrome in Selenium

    Posted by Sandeep Rathor | Last Updated: 06-Apr-17

    Selenium Webdriver is a Automation tool that is widely use in IT industry.

    Here are some steps you need to follow to open Chrome in Selenium

     

    After Installation of Webdriver, we just need to import the Jar file to perform certain tasks. In earlier Selenium 2 support by default Mozila Firefox browser. So now the Question is this how we can use the wedriver for other browser?

     

    To perform multiple operation on other browser we just need to install the .exe file for that particular browser and after that selenium support to run Webdriver accordingly we just need to write the selenium script by using the programing languages. 

     

    Most of the Web Application support Chorme because as compare to other Web browser chrome is mostly used by the people worldwide. So as a Tester there is compultion to test your web app on Chrome. To run the Selenium webdriver for Chrome, first we need to install the latest version of ChromeDriver for webdriver. If you are working on Windows than you need to download ChromeDriver jars according to Windows. You need to click on the "Chromedriver_win32.zip".

     

    After impoting the Jar files specify the path of the Chromedriver in your code, here giving an example of my code 

     

    import org.openqa.selenium.By;

    import org.openqa.selenium.WebDriver;

    import org.openqa.selenium.WebElement;

    import org.openqa.selenium.chrome.ChromeDriver;

    @Test

    public void testGoogleSearch() {

      // Optional, if not specified, WebDriver will search your path for chromedriver.

      System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");

     

      WebDriver driver = new ChromeDriver();

      driver.get("http://www.google.com/xhtml");

      Thread.sleep(5000);  // Let the user actually see something!

      WebElement searchBox = driver.findElement(By.name("q"));

      searchBox.sendKeys("ChromeDriver");

      searchBox.submit();

      Thread.sleep(5000);  // Let the user actually see something!

      driver.quit();

    }

    In above program we imported the two packages of chrome driver and by using WebDriver we initialize the driver.

     

    Thanks

Tags: selenium

Mobile Applications

Video Content

Bigdata & NoSQL

SaaS Applications

Miscellaneous

Archives


Alexa Certified Site Stats for www.oodlestechnologies.com