Skip to content

Commit

Permalink
[java] Implementing "minimize window" command
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Mar 12, 2020
1 parent 74179a8 commit 7b8ab9e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions java/client/src/org/openqa/selenium/WebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,14 @@ interface Window {
*/
void maximize();

/**
* Minimizes the current window if it is not already minimized
* <p>
* See <a href="https://w3c.github.io/webdriver/#minimize-window">W3C WebDriver specification</a>
* for more details.
*/
void minimize();

/**
* Fullscreen the current window if it is not already fullscreen
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ static CommandPayload SET_CURRENT_WINDOW_SIZE(Dimension targetSize) {
}
String GET_CURRENT_WINDOW_SIZE = "getCurrentWindowSize";
String MAXIMIZE_CURRENT_WINDOW = "maximizeCurrentWindow";
String MINIMIZE_CURRENT_WINDOW = "minimizeCurrentWindow";
String FULLSCREEN_CURRENT_WINDOW = "fullscreenCurrentWindow";

// Logging API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,11 @@ public void maximize() {
execute(DriverCommand.MAXIMIZE_CURRENT_WINDOW);
}

@Override
public void minimize() {
execute(DriverCommand.MINIMIZE_CURRENT_WINDOW);
}

@Override
public void fullscreen() {
execute(DriverCommand.FULLSCREEN_CURRENT_WINDOW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import static org.openqa.selenium.remote.DriverCommand.GET_WINDOW_HANDLES;
import static org.openqa.selenium.remote.DriverCommand.IS_ELEMENT_DISPLAYED;
import static org.openqa.selenium.remote.DriverCommand.MAXIMIZE_CURRENT_WINDOW;
import static org.openqa.selenium.remote.DriverCommand.MINIMIZE_CURRENT_WINDOW;
import static org.openqa.selenium.remote.DriverCommand.MOUSE_DOWN;
import static org.openqa.selenium.remote.DriverCommand.MOUSE_UP;
import static org.openqa.selenium.remote.DriverCommand.MOVE_TO;
Expand Down Expand Up @@ -131,6 +132,7 @@ public W3CHttpCommandCodec() {
alias(GET_SESSION_STORAGE_SIZE, EXECUTE_SCRIPT);

defineCommand(MAXIMIZE_CURRENT_WINDOW, post("/session/:sessionId/window/maximize"));
defineCommand(MINIMIZE_CURRENT_WINDOW, post("/session/:sessionId/window/minimize"));
defineCommand(GET_CURRENT_WINDOW_SIZE, get("/session/:sessionId/window/rect"));
defineCommand(SET_CURRENT_WINDOW_SIZE, post("/session/:sessionId/window/rect"));
alias(GET_CURRENT_WINDOW_POSITION, GET_CURRENT_WINDOW_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,11 @@ public void maximize() {
window.maximize();
}

@Override
public void minimize() {
window.minimize();
}

@Override
public void fullscreen() {
window.fullscreen();
Expand Down
12 changes: 12 additions & 0 deletions java/client/test/org/openqa/selenium/WindowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ public void testCanMaximizeTheWindowFromIframe() {
enlargeBy(WebDriver.Window::maximize);
}

@Test
@Ignore(travis = true)
public void canMinimizeTheWindow() {
// Browser window cannot be resized or moved on ANDROID (and most mobile platforms
// though others aren't defined in org.openqa.selenium.Platform).
assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID));

changeSizeTo(new Dimension(640, 323));
driver.manage().window().minimize();
// TODO: how to verify the result of this operation?
}

@Test
@Ignore(travis = true)
@Ignore(SAFARI)
Expand Down

0 comments on commit 7b8ab9e

Please sign in to comment.