How to properly run webdriver selenium chrome and firefox?

0

Hi, I've been watching tutorials on how to run selenium webdriver in firefox and in chrome but they do not work for me. Only the browser opens but it does not access the page I indicated, and it tries in several ways and it does not work for me, these are my codes

firefox 55 linux 64 bits

    System.setProperty("webdriver.firefox.bin", "/opt/firefox/firefox");

    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("marionette", false);
    WebDriver driver = new FirefoxDriver(capabilities); 

    driver.get("https://facebook.com");
    driver.close();
    driver.quit();

Google Chrome 61 linux 64 bits

 public static String driverPath = "/opt/google/chrome/google-chrome";
  public static WebDriver driver;

  public Pruebas()
  {
   System.out.println("launching chrome browser");
   System.setProperty("webdriver.chrome.driver", driverPath);
   driver = new ChromeDriver();
   driver.navigate().to("https://facebook.com");
  }

  public static void main(String[] args) {
   new Pruebas();
  }

Only opens the browsers but does not go to the page I indicated

google chorme: gives timeout error

firefox: Preferring the firefox binary in these options (/ opt / firefox / firefox rather than / opt / firefox / firefox)

    
asked by goku venz 10.09.2017 в 18:00
source

2 answers

1

Good afternoon,

What happens is that the selenium version you have is not compatible with your browser version, try this:

FIREFOX

WebDriver driver;
System.setProperty("webdriver.gecko.driver","/ruta/geckodriver.exe");
driver = new FirefoxDriver();

Download the geckodriver from: link

CHROME

System.setProperty("webdriver.chrome.driver","/ruta/chromedriver.exe");
driver = new ChromeDriver();

Download the chromedriver from: link

Finally:

driver.get("URL");
  

NOTE: You will not depend on your browsers, simply with the geckodriver it will raise firefox and with the chromedriver it will raise google chrome,

I hope you serve, greetings

    
answered by 27.09.2017 / 22:32
source
1

If you open the browser but do not interact with it, the most normal thing is that the versions between the browsers and selenium are misaligned.

For those versions that you indicate of the browsers I would use version 3.4 of selenium, with gecko driver for firefox in the version 0.18 and the last of Chrome driver, right now the 2.32

    
answered by 26.09.2017 в 11:30