5

Using selenium, I am initializing a firefox driver but, the chrome driver is initialized and chrome browser is opened.

Had I configured default settings anywhere? What could be the problem..Sorry for the dumb question.But, I got no clues.Please help.

Here goes my code,

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;


public class Aon
{
public static WebDriver driver;
public static void main(String[] args) {

System.setProperty("webdriver.gecko.driver", "C:/Users/ranganah/Downloads/Softwares/Selenium/geckodriver.exe");
    driver = new FirefoxDriver();
    driver.get("http://www.google.co.in");
    System.out.println(driver.getTitle());
    System.out.println(driver.getCurrentUrl());
    driver.findElement(By.name("q")).sendKeys("Hari");
    driver.findElement(By.name("q")).sendKeys(Keys.ENTER);

    System.out.println(driver.getTitle());
    System.out.println(driver.getCurrentUrl());
    driver.close();
    driver.quit();
   }
   }

For the screen shot: https://postimg.org/image/ncyg2o9l5/

  • Really?? provided code opens chrome browser instead?? – Saurabh Gaur Dec 12 '16 at 10:15
  • Check if you don't open Chrome from some other place. – Guy Dec 12 '16 at 10:16
  • Yes.With the errors below.Starting ChromeDriver 2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30) on port 11635 Only local connections are allowed. log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. – harinarayan Dec 12 '16 at 10:16
  • Could you share how you are defining `driver`?? I think this is not full code.. – Saurabh Gaur Dec 12 '16 at 10:18
  • @ Guy: This is the only code in the only class of a package.. – harinarayan Dec 12 '16 at 10:19
  • @SaurabhGaur Here it is,main thread updated – harinarayan Dec 12 '16 at 10:20
  • Could you share screenshot as well where have you written these code...?? – Saurabh Gaur Dec 12 '16 at 10:25
  • Instead of firefox,can you try opening IE and check what happens? – Sudharsan Selvaraj Dec 12 '16 at 10:26
  • @SudharsanSelvaraj The same thing happens if ie driver is used. – harinarayan Dec 12 '16 at 10:30
  • This is not possible, literally. can you add the screenshots of Chrome browser which is being launched? And the execution happened without any issues? check for errors in eclipse console – Naveen Kumar R B Dec 12 '16 at 10:31
  • @SaurabhGaur,Naveen, Please find SS in the main thread. – harinarayan Dec 12 '16 at 10:42
  • @harinarayan I think, you need to log a bug on selenium website..Thanks.. – Saurabh Gaur Dec 12 '16 at 10:48
  • Are you running it as "'Run As -> Java Application"? also, tell us the versions of Firefox, Chrome, Java, Selenium, Geckodriver versions – Naveen Kumar R B Dec 12 '16 at 10:49
  • @Naveen Yes, I am running it as "'Run As -> Java Application".Not working even if it is executed as a testng test.Selenium 3.0.1, Gecko driver 0.11.1, firefox 47.0.1.Note: I have been using only chrome for a while in my tests. – harinarayan Dec 12 '16 at 11:07
  • Geckodriver does not support FF47, following their [Github info](https://github.com/mozilla/geckodriver). `Firefox 47 is explicitly not supported.` I would try upgrading to FF48, at least. I have tried with FF50 and didn't find any problem. – Tom Dec 12 '16 at 13:07

1 Answers1

0

It is possible if you renamed chromedriver.exe to geckodriver.exe

Download geckodriver.exe from here and add it to the path and try.


Observed that when we rename chromedriver.exe to geckodriver.exe, though you create an instance of Firefox/InternetExplorer Driver, it will launch Chrome browser.

Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65
  • Thats a good try naveen. But, seems like its not the case..:) – harinarayan Dec 12 '16 at 11:29
  • @harinarayan, have you tried it out? Firefox 47.0.1 is the version from which geckodriver support. so, it might be an issue with the geckodriver. I suggest following actions to perform in the listed manner 1. Restart the machine and run. If not working, 2. Upgrade the browser to the latest one (50.0.2 as of now) and use the latest geckodriver and try. similar issue I have faced. more details here http://stackoverflow.com/questions/40269229/python-selenium-3-0-firefox-47-0-1-installed-in-default-location-is-not-identi – Naveen Kumar R B Dec 12 '16 at 11:39
  • 1
    Firefox 47 is explicitly not supported by geckodriver.more details here https://github.com/mozilla/geckodriver#supported-firefoxen & https://github.com/mozilla/geckodriver/issues/224 – Naveen Kumar R B Dec 12 '16 at 11:49
  • @ Naveen, Tom The problem occurs only for the specific class and package. When I create a new project, it works fine with same firefox and gecko driver. – harinarayan Dec 13 '16 at 07:48
  • Are you using any framework like JUnit or TestNG to run your tests (the specific class)? – Naveen Kumar R B Dec 13 '16 at 08:21
  • No, as mentioned earlier, its a simple java class – harinarayan Dec 13 '16 at 08:25
  • I am not sure what is the reason, you can continue with the new project. right? – Naveen Kumar R B Dec 13 '16 at 08:27