Skip to content

Commit f1e491e

Browse files
committed
adding selenium server pass throughs for W3C dialect of alert / window / cookie commands.
changing how W3C dialect is detected by checking if 'status' is sent in the new session response switch to window in w3c passes in 'handle' variable instead of 'name' Fixes #1242 Fixes #1241 Fixes #1240 Fixes #1238 Fixes #1237
1 parent 9d157ae commit f1e491e

28 files changed

+404
-141
lines changed

java/client/src/org/openqa/selenium/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ java_library(name = 'primitives',
120120
srcs = [
121121
'Dimension.java',
122122
'Point.java',
123+
'Rectangle.java',
123124
],
124125
visibility = [
125126
'//java/client/src/org/openqa/selenium/interactions:core',
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.openqa.selenium;
19+
20+
public class Rectangle {
21+
22+
public int x;
23+
public int y;
24+
public int height;
25+
public int width;
26+
27+
public Rectangle(int x, int y, int height, int width) {
28+
this.x = x;
29+
this.y = y;
30+
this.height = height;
31+
this.width = width;
32+
}
33+
34+
public Rectangle(Point p, Dimension d) {
35+
x = p.x;
36+
y = p.y;
37+
height = d.height;
38+
width = d.width;
39+
}
40+
41+
public int getX() {
42+
return x;
43+
}
44+
45+
public int getY() {
46+
return y;
47+
}
48+
49+
public void setX(int x) {
50+
this.x = x;
51+
}
52+
53+
public void setY(int y) {
54+
this.y = y;
55+
}
56+
57+
public int getHeight() {
58+
return height;
59+
}
60+
61+
public void setHeight(int height) {
62+
this.height = height;
63+
}
64+
65+
public int getWidth() {
66+
return width;
67+
}
68+
69+
public void setWidth(int width) {
70+
this.width = width;
71+
}
72+
73+
public Point getPoint() {
74+
return new Point(x, y);
75+
}
76+
77+
public Dimension getDimension() {
78+
return new Dimension(x, y);
79+
}
80+
}

java/client/src/org/openqa/selenium/WebDriver.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ interface Options {
238238
/**
239239
* @return the interface for managing the current window.
240240
*/
241-
@Beta
242241
Window window();
243242

244243
/**
@@ -508,5 +507,10 @@ interface Window {
508507
* Maximizes the current window if it is not already maximized
509508
*/
510509
void maximize();
510+
511+
/**
512+
* Fullscreen the current window if it is not already fullscreen
513+
*/
514+
void fullscreen();
511515
}
512516
}

java/client/src/org/openqa/selenium/WebElement.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ public interface WebElement extends SearchContext, TakesScreenshot {
194194
*/
195195
Dimension getSize();
196196

197+
/**
198+
* @return The location and size of the rendered element
199+
*/
200+
Rectangle getRect();
201+
197202
/**
198203
* Get the value of a given CSS property.
199204
* Color values should be returned as rgba strings, so,

java/client/src/org/openqa/selenium/build.desc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ java_library(name = "webdriver-api",
4848
"NotFoundException.java",
4949
"OutputType.java",
5050
"Proxy.java",
51+
"Rectangle.java",
5152
"Rotatable.java",
5253
"ScreenOrientation.java",
5354
"SearchContext.java",

java/client/src/org/openqa/selenium/firefox/MarionetteDriver.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ public MarionetteDriver(GeckoDriverService service, Capabilities capabilities,
7373
run(service, capabilities);
7474
}
7575

76-
@Override
77-
public int getW3CStandardComplianceLevel() {
78-
return 1;
79-
}
80-
8176
private void run(GeckoDriverService service, Capabilities capabilities) {
8277
setCommandExecutor(new DriverCommandExecutor(service));
8378

java/client/src/org/openqa/selenium/htmlunit/HtmlUnitDriver.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,11 @@ public void maximize() {
16781678
setSize(initialWindowDimension);
16791679
setPosition(new Point(0, 0));
16801680
}
1681+
1682+
@Override
1683+
public void fullscreen() {
1684+
maximize();
1685+
}
16811686
}
16821687

16831688
@Override

java/client/src/org/openqa/selenium/htmlunit/HtmlUnitWebElement.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.openqa.selenium.NoSuchElementException;
3535
import org.openqa.selenium.OutputType;
3636
import org.openqa.selenium.Point;
37+
import org.openqa.selenium.Rectangle;
3738
import org.openqa.selenium.StaleElementReferenceException;
3839
import org.openqa.selenium.WebDriver;
3940
import org.openqa.selenium.WebDriverException;
@@ -513,6 +514,10 @@ public Dimension getSize() {
513514
}
514515
}
515516

517+
public Rectangle getRect() {
518+
return new Rectangle(getLocation(), getSize());
519+
}
520+
516521
private int readAndRound(final String property) {
517522
final String cssValue = getCssValue(property).replaceAll("[^0-9\\.]", "");
518523
if (cssValue.length() == 0) {

java/client/src/org/openqa/selenium/remote/DriverCommand.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public interface DriverCommand {
4040

4141
String ADD_COOKIE = "addCookie";
4242
String GET_ALL_COOKIES = "getCookies";
43+
String GET_COOKIE = "getCookie";
4344
String DELETE_COOKIE = "deleteCookie";
4445
String DELETE_ALL_COOKIES = "deleteAllCookies";
4546

@@ -56,8 +57,9 @@ public interface DriverCommand {
5657
String UPLOAD_FILE = "uploadFile";
5758

5859
String GET_CURRENT_WINDOW_HANDLE = "getCurrentWindowHandle";
59-
String GET_CURRENT_WINDOW_HANDLE_LEVEL_1 = "getCurrentWindowHandleLevel1";
6060
String GET_WINDOW_HANDLES = "getWindowHandles";
61+
String GET_WINDOW_HANDLES_W3C = "getWindowHandlesW3C";
62+
String GET_CURRENT_WINDOW_HANDLE_W3C = "getCurrentWindowHandleW3C";
6163

6264
String GET_CURRENT_CONTEXT_HANDLE = "getCurrentContextHandle";
6365
String GET_CONTEXT_HANDLES = "getContextHandles";
@@ -74,6 +76,8 @@ public interface DriverCommand {
7476

7577
String EXECUTE_SCRIPT = "executeScript";
7678
String EXECUTE_ASYNC_SCRIPT = "executeAsyncScript";
79+
String EXECUTE_SCRIPT_W3C = "executeScriptW3C";
80+
String EXECUTE_ASYNC_SCRIPT_W3C = "executeAsyncScriptW3C";
7781

7882
String GET_ELEMENT_TEXT = "getElementText";
7983
String GET_ELEMENT_TAG_NAME = "getElementTagName";
@@ -97,6 +101,11 @@ public interface DriverCommand {
97101
String SET_ALERT_VALUE = "setAlertValue";
98102
String SET_ALERT_CREDENTIALS = "setAlertCredentials";
99103

104+
String ACCEPT_ALERT_W3C = "acceptAlertW3C";
105+
String DISMISS_ALERT_W3C = "dimissAlertW3C";
106+
String GET_ALERT_TEXT_W3C = "getAlertTextW3C";
107+
String SET_ALERT_VALUE_W3C = "setAlertValueW3C";
108+
100109
String SET_TIMEOUT = "setTimeout";
101110
String IMPLICITLY_WAIT = "implicitlyWait";
102111
String SET_SCRIPT_TIMEOUT = "setScriptTimeout";
@@ -165,6 +174,7 @@ public interface DriverCommand {
165174
String SET_CURRENT_WINDOW_SIZE = "setCurrentWindowSize";
166175
String GET_CURRENT_WINDOW_SIZE = "getCurrentWindowSize";
167176
String MAXIMIZE_CURRENT_WINDOW = "maximizeCurrentWindow";
177+
String FULLSCREEN_CURRENT_WINDOW = "fullscreenCurrentWindow";
168178

169179
// Logging API
170180
String GET_AVAILABLE_LOG_TYPES = "getAvailableLogTypes";

java/client/src/org/openqa/selenium/remote/ErrorCodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public boolean isMappableError(Throwable thrown) {
248248
return statusCode != SUCCESS && statusCode != UNHANDLED_ERROR;
249249
}
250250

251-
public static String toState(int status) {
251+
public static String toState(Integer status) {
252252
return statusToState.get(status);
253253
}
254254

0 commit comments

Comments
 (0)