上下文:从以下代码中获取错误作为方法 chrome 未定义:
package zapSeleniumIntegration;
import java.lang.reflect.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class BrowserDriverFactory {
static WebDriver driver;
public static WebDriver createChromeDriver(Proxy proxy, String path) {
// Set proxy in the chrome browser
DesiredCapabilities capabilities = DesiredCapabilities.chrome();//Getting error as method chrome undefined
capabilities.setCapability("127.0.0.1", 8080);
// Set system property for chrome driver with the path
System.setProperty("webdriver.chrome.driver", "C:\\Users\\kotla.naveen\\Desktop\\chromedriver.exe");
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
ChromeOptions options = new ChromeOptions();
options.merge(capabilities);
return new ChromeDriver(options);
}
}