Skip to content

Commit

Permalink
[js] Minimize window and fullscreen window APIs
Browse files Browse the repository at this point in the history
For #4290
  • Loading branch information
jleyba committed Oct 9, 2017
1 parent f9b221f commit 73d1654
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
11 changes: 7 additions & 4 deletions javascript/node/selenium-webdriver/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ mode.

### API Changes

* Added `webdriver.manage().window().minimize()`
* Added `webdriver.manage().window().fullscreen()`
* The core WebDriver API no longer uses promise manager
- Removed `index.Builder#setControlFlow()`
- The following thenable types no longer have a `cancel()` method:
Expand All @@ -34,10 +36,11 @@ mode.

### Changes for W3C WebDriver Spec Compliance

Revamped the actions API to conform with the WebDriver Spec:
<https://www.w3.org/TR/webdriver/#actions>. For details, refer to the JS doc
on the `lib/webdriver.ActionSequence` class. For simplicity, support for the
legacy actions API has been removed.
* Revamped the actions API to conform with the WebDriver Spec:
<https://www.w3.org/TR/webdriver/#actions>. For details, refer to the JS doc
on the `lib/webdriver.ActionSequence` class. For simplicity, support for the
legacy actions API has been removed.
* Added supported for minimizing windows and toggling fullscreen.


## v3.6.0
Expand Down
2 changes: 2 additions & 0 deletions javascript/node/selenium-webdriver/lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ const Name = {
GET_WINDOW_SIZE: 'getWindowSize',
SET_WINDOW_SIZE: 'setWindowSize',
MAXIMIZE_WINDOW: 'maximizeWindow',
MINIMIZE_WINDOW: 'minimizeWindow',
FULLSCREEN_WINDOW: 'fullscreenWindow',

SWITCH_TO_WINDOW: 'switchToWindow',
SWITCH_TO_FRAME: 'switchToFrame',
Expand Down
2 changes: 2 additions & 0 deletions javascript/node/selenium-webdriver/lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ const W3C_COMMAND_MAP = new Map([
[cmd.Name.EXECUTE_SCRIPT, post('/session/:sessionId/execute/sync')],
[cmd.Name.EXECUTE_ASYNC_SCRIPT, post('/session/:sessionId/execute/async')],
[cmd.Name.MAXIMIZE_WINDOW, post('/session/:sessionId/window/maximize')],
[cmd.Name.MINIMIZE_WINDOW, post('/session/:sessionId/window/minimize')],
[cmd.Name.FULLSCREEN_WINDOW, post('/session/:sessionId/window/fullscreen')],
[cmd.Name.GET_WINDOW_POSITION, get('/session/:sessionId/window/position')],
[cmd.Name.SET_WINDOW_POSITION, post('/session/:sessionId/window/position')],
[cmd.Name.GET_WINDOW_SIZE, get('/session/:sessionId/window/size')],
Expand Down
37 changes: 34 additions & 3 deletions javascript/node/selenium-webdriver/lib/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1592,15 +1592,46 @@ class Window {
}

/**
* Maximizes the current window.
* @return {!Promise<void>} A promise that will be resolved
* when the command has completed.
* Maximizes the current window. The exact behavior of this command is
* specific to individual window managers, but typically involves increasing
* the window to the maximum available size without going full-screen.
*
* @return {!Promise<void>} A promise that will be resolved when the command
* has completed.
*/
maximize() {
return this.driver_.execute(
new command.Command(command.Name.MAXIMIZE_WINDOW).
setParameter('windowHandle', 'current'));
}

/**
* Minimizes the current window. The exact behavior of this command is
* specific to individual window managers, but typicallly involves hiding
* the window in the system tray.
*
* @return {!Promise<void>} A promise that will be resolved when the command
* has completed.
*/
minimize() {
return this.driver_.execute(
new command.Command(command.Name.MINIMIZE_WINDOW));
}

/**
* Invokes the "full screen" operation on the current window. The exact
* behavior of this command is specific to individual window managers, but
* this will typically increase the window size to the size of the physical
* display and hide the browser chrome.
*
* @return {!Promise<void>} A promise that will be resolved when the command
* has completed.
* @see <https://fullscreen.spec.whatwg.org/#fullscreen-an-element>
*/
fullscreen() {
return this.driver_.execute(
new command.Command(command.Name.FULLSCREEN_WINDOW));
}
}


Expand Down

0 comments on commit 73d1654

Please sign in to comment.