Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I am new to selenium webdriver and by default when i run a script it is opening a session in Firefox. now i want to open this session in other browsers like Google Chrome, IE.

How can i open this sessions?

Thanks Kamlesh

share|improve this question

3 Answers 3

To create an instance of a browser when running WebDriver test you need to create an a driver specific to that browser. Firefox works by default, but to work with other browsers such as chrome you may have to download the driver separately.

This is website will give you information on how to install the chrome driver and how to get it running.

You will need to have chrome install on your test machine as well. Other drivers for other browsers can be install in the same manner.

share|improve this answer
    package mercuryreg;
    import java.util.regex.Pattern;
    import java.util.concurrent.TimeUnit;
    import org.junit.*;
    import static org.junit.Assert.*;
    import static org.hamcrest.CoreMatchers.*;  
    import org.openqa.selenium.*;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.support.ui.Select;
    import com.thoughtworks.selenium.webdriven.commands.IsElementPresent;

    public class MercuryReg {

      @Test
      public void mMercuryReg() throws Exception {

          System.setProperty("webdriver.chrome.driver", "E:\\Softwares_Must_Have\\sele\\chromedriver\\chromedriver.exe");

            WebDriver driver = new ChromeDriver(); 
            driver.manage().window().maximize();


            //Open Home Page
            driver.get("http://newtours.demoaut.com/mercuryregister.php?osCsid=78d86f0aad105bdce1a01c8531e3b2c6");
            //Enter text in search box
            WebElement fname=driver.findElement(By.name("firstName"));
            fname.clear();
            fname.sendKeys("firstName");

............
..........
........
.......
.....
...
..
.
share|improve this answer
    
It would help if you explained what your code is doing to open the session in different browsers instead of just pasting code. That will make your answer useful to anyone looking for this information. –  Kate Paulk Jul 15 at 10:59
System.setProperty("webdriver.chrome.driver", "E:\\Softwares_Must_Have\\sele\\chromedriver\\chromedriver.exe");
     WebDriver driver = new ChromeDriver(); 

this is the syntax to locate the third party driver,. you have to download the driver. then you have to initiate and call it..

thanks Prakash and am new to stackexchange..

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.