operachromiumdriver
operachromiumdriver copied to clipboard
driver.manage().window().setSize does not work in private mode
The following code does not work in private mode:
Window window = driver.manage().window();
window.setPosition(new Point(0, 0));
window.setSize(new Dimension(width, height));
The code which creates drivers:
DesiredCapabilities capabilities = DesiredCapabilities.operaBlink();
capabilities.setBrowserName("opera");
OperaOptions options = new OperaOptions();
options.addArguments("private");
capabilities.setCapability(OperaOptions.CAPABILITY, options);
WebDriver driver = new OperaDriver(capabilities);
I know that I can pass arguments to drivers using OperaOptions
, but I would like to change size during tests executions.
Logs:
Starting OperaDriver 0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96) on port 22946
Only local connections are allowed.
Tests run: 10, Failures: 1, Errors: 0, Skipped: 9, Time elapsed: 4.975 sec <<< FAILURE! - in TestSuite
beforeEachTest(com.hybris.testing.backoffice.login.BackofficeEditProductTest) Time elapsed: 4.597 sec <<< FAILURE!
org.openqa.selenium.WebDriverException: unknown error: No current window
JavaScript stack:
Error: No current window
at checkForExtensionError (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:14:17)
at Object.callback (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:67:5)
at safeCallbackApply (extensions::sendRequest:21:15)
at handleResponse (extensions::sendRequest:72:7)
(Session info: Opera with embedded Chromium 49.0.2623.87)
(Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 10.0 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 37 milliseconds
The same error occurred in Chrome (see Issue 1350).
I'm temporary solved this by code:
driver.get("chrome://extensions");
WebElement checkbox = driver.findElement(By.xpath("//div[contains(@class, 'incognito-control')]/label/input[@type='checkbox']"));
if (!checkbox.isSelected()) {
checkbox.click();
}
The solution is based on code added to comment of the Issue 513.