Java Eclipse - ожидать двоичное расположение браузера - PullRequest
0 голосов
/ 01 октября 2018

Я пытаюсь запустить следующий код Java:

package tests;

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

public class sekcija9 {

    public static void main(String[] args) {        
        System.setProperty("webdriver.gecko.driver","C:\\Program Files\\Mozilla Firefox\\geckodriver.exe");

        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
    }
}

Я получаю следующую ошибку:

Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

Я использую:

  1. Firefox 62.0.2 64-бит

  2. Селен 3.3.1

  3. GeckoDriver 0.22.0 (последняя версия)

Я посмотрел здесь: ссылка

Нужно ли понижать версию Firefox?Если нет, как я могу решить эту проблему без понижения?

Ответы [ 2 ]

0 голосов
/ 01 октября 2018

это должно работать:

public static void main(String[] args) {        
        FirefoxOptions options = new FirefoxOptions();
        options.setBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
        System.setProperty("webdriver.gecko.driver","C:\\Program Files\\Mozilla Firefox\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver(options);
        driver.get("http://www.google.com");
    }
0 голосов
/ 01 октября 2018

Попробуйте приведенный ниже код, а также убедитесь, что ваша версия Firefox совместима с драйверами Gecko.

   import org.openqa.selenium.Platform;
   import org.openqa.selenium.WebDriver;
   import org.openqa.selenium.firefox.FirefoxDriver;
   import org.openqa.selenium.remote.DesiredCapabilities;
   public class geckodriver {
       public static void main(String[] args) throws InterruptedException {

             System.setProperty("webdriver.gecko.driver", "C:\\Users\\username\\Downloads\\geckodriver-v0.20.1-win64\\geckodriver.exe");
           Thread.sleep(5000);
//           DesiredCapabilities capabilities = DesiredCapabilities.firefox();
//            capabilities.setCapability("marionette", true);
//           
//           WebDriver driver = new FirefoxDriver(capabilities);

           DesiredCapabilities capabilities = new DesiredCapabilities();

           capabilities = DesiredCapabilities.firefox();
           capabilities.setBrowserName("firefox");
           capabilities.setVersion("your firefox version");
           capabilities.setPlatform(Platform.WINDOWS);
           capabilities.setCapability("marionette", false);

           WebDriver driver = new FireFoxDriver(capabilities);

             driver.get("http://www.google.com");

             Thread.sleep(5000);
             driver.quit();
}}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...