Example:
Opera One(version: 109.0.5097.68)
Update checker is disabled
Update stream:Stable
System:Windows 10 64-bit
Chromium version:123.0.6312.124
private void startOperaBrowser() {
//System.setProperty("webdriver.opera.driver", "C:\\webdrivers\\operadriver_win32\\operadriver.exe");
System.setProperty("webdriver.opera.driver", "C:\\webdrivers\\operadriver_win64\\operadriver.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
OperaOptions options = new OperaOptions();
options.setBinary("D:\\Opera999\\001\\opera.exe");
//Its Default profile location, Portable USB Opera profile\data
String PROFILE_PATH = "D:\\Opera999\\001\\profile\\data";
options.addArguments(Arrays.asList(
// "disable-infobars",
// "--remote-debuggin-port=9222",
// "--no-sandbox",
// "--ignore-certificate-errors",
"--user-data-dir=" + PROFILE_PATH
// "--homepage=https://google.com",
// "--no-first-run"
));
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
OperaDriver driver = new OperaDriver(capabilities);
// It may not work if the browser starts with previous profile tabs and loads something, it’s better to start one tab
//obtain browser capabilities
Capabilities cap = ((RemoteWebDriver) driver).getCapabilities();
Map<String, Object> mp = cap.asMap();
mp.forEach((key, value) -> {
System.out.println("Key is: " + key + " Value is: " + value);
});
//implicit wait
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//url launch
driver.get("opera://about");
//It may not work if the browser starts with previous profile tabs and loads something, it’s better to start one tab
}
private static OperaDriver attach_toProcess_opera(int port) {
System.setProperty("webdriver.opera.driver", "C:\\webdrivers\\operadriver_win64\\operadriver.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
OperaOptions op = new OperaOptions();
//configure debuggerAddress value
op.setExperimentalOption("debuggerAddress", "localhost:" + port);
capabilities.setCapability(OperaOptions.CAPABILITY, op);
OperaDriver driver = new OperaDriver(capabilities);
Capabilities cap = driver.getCapabilities();
Map<String, Object> mp = cap.asMap();
mp.forEach((key, value) -> {
System.out.println("[" + port + "] Key is: " + key + " Value is: " + value);
});
return driver;
}
private void test(RemoteWebDriver[] drivers) {
for (int i = 0; i < 100; i++) {
for (RemoteWebDriver driver : drivers) {
driver.get("https://google.com");//get() Not wortk if current url in tab == "opera://about"
System.out.println("@!@@@@@@");
}
}
}
Driver
https://github.com/operasoftware/operachromiumdriver/releases
Комментариев нет:
Отправить комментарий