With the below code block it opens a chrome browser fine it just won't full screen the browser using F11. i used to use C# and selenium and that worked fine using this method on chrome and different browsers. It finds the element 'body' but then does not send the key press. Am I doing something wrong here that i should be requiring some other library?
the documentation for webdriverjs is pathetic and there is very few examples, I am seriously considering dumping it for something else possibly python.
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('/');
driver.wait(function () {
return driver.getTitle().then(function (title) {
return title === 'Google';
});
}, 1000);
driver.findElement(webdriver.By.xpath('/html/body')).sendKeys("F11");
why are we doing this. we are developing a website that will change depending on size 800x600 + with and without the toolbar depending on how the screen is used different items will be displayed. i can maximise the window using,
driver.manage().window().maximize();
This however still leaves the toolbar present and doesn't act as if the user has pressed the F11 key.
With the below code block it opens a chrome browser fine it just won't full screen the browser using F11. i used to use C# and selenium and that worked fine using this method on chrome and different browsers. It finds the element 'body' but then does not send the key press. Am I doing something wrong here that i should be requiring some other library?
the documentation for webdriverjs is pathetic and there is very few examples, I am seriously considering dumping it for something else possibly python.
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('https://www.google.co.uk/');
driver.wait(function () {
return driver.getTitle().then(function (title) {
return title === 'Google';
});
}, 1000);
driver.findElement(webdriver.By.xpath('/html/body')).sendKeys("F11");
why are we doing this. we are developing a website that will change depending on size 800x600 + with and without the toolbar depending on how the screen is used different items will be displayed. i can maximise the window using,
driver.manage().window().maximize();
This however still leaves the toolbar present and doesn't act as if the user has pressed the F11 key.
Share Improve this question edited Oct 12, 2017 at 9:18 trevellyon asked Jan 20, 2014 at 17:00 trevellyontrevellyon 1132 silver badges14 bronze badges 6- 1 There is already the ability to maximise the window: github./SeleniumHQ/selenium/blob/master/javascript/webdriver/… – Arran Commented Jan 20, 2014 at 17:13
- The difference is that F11 hides the web address bar, and any other tool bars. – Richard Commented Jan 20, 2014 at 17:15
- @Richard and that's practical, how? – ddavison Commented Jan 20, 2014 at 17:56
- in the website we are creating it has to be full screen for operational purposes therefore the address bar is not needed the maximize is not what i need (however i can get that to work :D) – trevellyon Commented Jan 21, 2014 at 11:37
- Hello! So did you fix that problem? I also want to open the browser in fullscreen not just maximized. kind regards Margo – Margo Commented Aug 19, 2015 at 12:03
6 Answers
Reset to default 4it tooks some time to find it but you should have all the Keys in webdriver.Key
driver.findElement(webdriver.By.xpath('/html/body')).sendKeys(webdriver.Key.F11);
Hope it helps!
A co-worker has just discovered that it works well in C# with:
Driver.Instance.Manage().Window.FullScreen();
from selenium.webdriver.mon.keys import Keys
from selenium.webdriver.mon.action_chains import ActionChains
ActionChains(driver).send_keys(Keys.F11).perform()
I use a similar mand to toggle JS via Firefox's NoScript add-on
edit: I just tested, and it works!
For me the one emulating correctly the F11 on startup is:
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-fullscreen");
WebDriver driver = new ChromeDriver(options);
Or if the kiosk mode is preferred:
ChromeOptions options = new ChromeOptions();
options.addArguments("--kiosk");
WebDriver driver = new ChromeDriver(options);
This should work for you:
driver.findElement(webdriver.By.xpath('/html/body')).sendKeys(Keys.F11);
You can maximise the window using:
driver.manage().window().maximize();