Метод firefox() не определен для типа DesiredCapabilities.

Я пытаюсь запустить сетку селена на своем компьютере и получаю следующее для всех браузеров в cap = DesiredCapabilities.firefox();: Метод firefox() не определен для типа DesiredCapabilities

Ниже мой код

пакет параллельный;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class GridTest {


public WebDriver driver=null;

    @Parameters("browser") //testng.xml
    @Test()
public void googleTest(String b) throws MalformedURLException, InterruptedException{

    System.out.println("Google " + b);

    DesiredCapabilities cap = null;

    if(b.equals("firefox")){
        cap = DesiredCapabilities.firefox();
        cap.setBrowserName("firefox"); 
        cap.setPlatform(Platform.ANY);
    }else if (b.equals("chrome")){
        cap = DesiredCapabilities.chrome(); 
        cap.setBrowserName("chrome");
        cap.setPlatform(Platform.ANY);
    }else if (b.equals("iexplore")){
        cap = DesiredCapabilities.internetExplorer(); 
        cap.setBrowserName("iexplore");
        cap.setPlatform(Platform.WINDOWS);
    }

    try{driver = new RemoteWebDriver(new URL("http://10.0.30.240:4446/wd/hub"),cap);
} catch (MalformedURLException e) {


    driver.get("http://google.com");
    driver.findElement(By.name("q")).sendKeys("Hello "+b);
    Thread.sleep(2000);


    driver.quit();

}}}

person SUPARNA SOMAN    schedule 30.07.2019    source источник
comment
Вам нужно использовать класс Firefox::Options .DesiredCapabilities устарел в последней версии селена.   -  person Rahul L    schedule 31.07.2019


Ответы (1)


Добавление автономного сервера selenium в мой pom.xml устранило проблему:

<!--  https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server-standalone -->
  <dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-server</artifactId>
  <version>3.4.0</version>
</dependency>
person SUPARNA SOMAN    schedule 30.07.2019