1
votes

I am trying to use eclipse to run Selenium web-driver automation but unable to open a browser window. Debug logs are showing that there is no error and I am successfully able to retrieve title of the web page as shown below:

try {
        System.setProperty("webdriver.gecko.driver","/Users/shankar.sharma/Downloads/chrome-driver/geckodriver");

        DesiredCapabilities cap = DesiredCapabilities.firefox();
        cap.setCapability("marionette", true);

        FirefoxOptions options = new FirefoxOptions();
        options.addPreference("log", "{level: error}");

        WebDriver driver = new FirefoxDriver();
        driver.navigate().to("http://www.seleniumhq.org/download/");
        String appTitle = driver.getTitle();
        System.out.println("Application title is :: "+appTitle);
        driver.quit();
    } catch (Exception e) {
        System.out.println("Exception:"+e.getMessage());
    }

Debug Logs: 1496221115902 geckodriver INFO Listening on 127.0.0.1:39119 1496221116097 geckodriver::marionette INFO Starting browser /Applications/Firefox.app/Contents/MacOS/firefox-bin with args ["-marionette"] 1496221117678 Marionette INFO Listening on port 63210 May 31, 2017 2:28:38 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C 2017-05-31 14:28:38.036 plugin-container[55325:3295542] * CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x9c3b, name = 'com.apple.tsm.portname' See /usr/include/servers/bootstrap_defs.h for the error codes. 2017-05-31 14:28:38.038 plugin-container[55325:3295542] * CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x9f03, name = 'com.apple.CFPasteboardClient' See /usr/include/servers/bootstrap_defs.h for the error codes. Application title is :: Downloads 1496221129876 Marionette INFO New connections will no longer be accepted

But browser window is not opening. I have also tried with chrome driver but that is also not working. I am using below configurations :

  • Selenium Web-driver : 3.4.0
  • LGecko driver : v0.16.0

Any ideas about the cause why this is happening?

2
your geckodriver property is incorrect. - Debuggerrr
@SiddheshKalgaonkar I think path is correct. If I add .exe extension, then it stops working. - Shankar Sharma
i edited my comment and if you add .exe it should not stop working .please refer my answer - Debuggerrr
If I change anything in this path, it gives "The driver executable does not exist" error. - Shankar Sharma
which version of firefox / chrome browser you are using? - santhosh kumar

2 Answers

1
votes

I have checked the same in my mac but its working fine for me.. Below is the default code for which i can see the browser has been getting launched automatically...

 public static void main(String[] args) 
{ 
   System.setProperty("webdriver.chrome.driver", "/Users/santhoshkumar/Documents/Softwares/chromedriver"); 
   driver.manage().windows().maximize();
   WebDriver driver = new ChromeDriver(); 
   driver.get("http://facebook.com"); 
   System.out.println(driver.getTitle()); 
}

Since this is not working for you.. Try to use chromeoptions..

public static void main(String[] args) 
{ 
  System.setProperty("webdriver.chrome.driver", "/Users/santhoshkumar/Documents/Softwares/chromedriver"); 
  ChromeOptions options = new ChromeOptions(); 
  options.addArguments("start-maximized"); 
  options.addArguments("--start-fullscreen");
  WebDriver driver = new ChromeDriver(options); 
  driver.get("http://facebook.com"); 
  System.out.println(driver.getTitle()); 
}

Hope this helps you. Thanks.

0
votes

Go through my answer on this link and make sure that your browser firefox version is below 48.0
Enjoy :)