Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to sendkeys using webdriverjs specifically F11 to maximise the browser

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.

like image 839
trevellyon Avatar asked Jan 20 '14 17:01

trevellyon


2 Answers

it 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!

like image 84
Andre989 Avatar answered Oct 05 '22 04:10

Andre989


A co-worker has just discovered that it works well in C# with:

Driver.Instance.Manage().Window.FullScreen(); 
like image 32
Lord PK Avatar answered Oct 05 '22 02:10

Lord PK