SELENIUM problem when trying to connect to the firefox driver

2
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import com.gargoylesoftware.htmlunit.javascript.host.file.File;
import interfaz.interfaz;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;

/**
 *
 * @author Josel
 */
public class test {

    public static void main(String[] args) {

       WebDriver driver;
       System.setProperty("webdriver.gecko.driver", "C:\Program Files (x86)\Mozilla Firefox\firefox.exe");
       driver =new FirefoxDriver();
       driver.get("www.google.com");
       driver.close();

    }

}

When I run it, firefox opens but the page I'm putting does not come out and it goes blank, a subwindow opens asking me if I save firefox.exe

    
asked by Selito95 10.07.2017 в 20:58
source

2 answers

1

In this line you must indicate the firefox webdriver, not the executable of the application.

System.setProperty("webdriver.gecko.driver", "C:\Program Files (x86)\Mozilla Firefox\firefox.exe");

If you are setting the property as a gecko, you must indicate the downloaded webdriver from here

Changing that line for something like this:

 System.setProperty("webdriver.gecko.driver", "\dondeesteladescarga\geckodriver_v0.18.exe")
    
answered by 26.09.2017 в 12:46
0

Download the geckodriver from:

link

Try it like this:

public class test {

public static void main(String[] args) {

   WebDriver driver;
   System.setProperty("webdriver.gecko.driver", "/ruta/geckodriver.exe");
   driver =new FirefoxDriver();
   driver.get("www.google.com");
   driver.close();
}}

It should work without problems

    
answered by 27.09.2017 в 22:40