I'm working on application which will execute tests on multiple browser types (Chrome, FireFox, Internet Explorer and Opera). I found the way how to launched them in incognito/private modes (How to open incognito/private window with Selenium WD for different browser types?) and set window size (Browser window control #174):
Window window = driver.manage().window();
window.setPosition(new Point(0, 0));
window.setSize(new Dimension(width, height));
But this code does not work in all cases:
+-------------------+----------+-------------------+
| Browser | Standard | Incognito/Private |
|-------------------|----------|-------------------|
| Chrome | works | does not work |
|-------------------|----------|-------------------|
| FireFox | works | works |
|-------------------|----------|-------------------|
| Internet Explorer | works | works |
|-------------------|----------|-------------------|
| Opera | works | does not work |
+-------------------+----------+-------------------+
How to solve this problem? I know that I can pass arguments to drivers using ChromeOptions
and OperaOptions
. But I would like to change size during tests executions. It will be great if I don't need to eval JavaScript.
Hi we can set the size of the browser using the dimension class.The dimension class provides the method called .using it we can do . Example for setting the size of is :
The are some problems with automation testing in Chrome and Opera browsers.
Issues:
I temporary solved them using the code:
Chrome
Opera:
Hi in Google chrome (incog mode) i think re-sizing is not possible.re-sizing in normal instance of google chrome is possible but not with incog mode on.with doing more research i closely observed the error shown in eclipse (incog mode on)
you can see at line checkForExtensionError you will find that why its not possible.
1.please open chrome://extensions/ in chrome and enable developer option then
2.under Chrome Automation Extension you will see the same ID that is shown in the error (posted above).
4.Please open the location of the manifest.json under Loaded from: inside that you will find the below contents
under description u can clearly see that
Hence if Point 3 is not enabled it is not possible to automate anything with webdriver in chrome.
Also i do not know how to enable point 3 via automation if you can then you can surely resize window in incog mode. hope this helps
This is an alternative to set the size of the window once the browser is launched: