Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions java/src/org/openqa/selenium/devtools/CdpClientGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1021,11 +1021,13 @@ public TypeDeclaration<?> toTypeDeclaration() {
.get()
.addStatement(
String.format(
"return java.util.Arrays.stream(%s.values())\n"
+ ".filter(rs -> rs.value.equalsIgnoreCase(s))\n"
+ ".findFirst()\n"
+ ".orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException(\n"
+ "\"Given value \" + s + \" is not found within %s \"));",
"""
return java.util.Arrays.stream(%s.values())
.filter(rs -> rs.value.equalsIgnoreCase(s))
.findFirst()
.orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException(
"Given value " + s + " is not found within %s "));\
""",
name, name));

enumDecl
Expand Down
9 changes: 6 additions & 3 deletions java/src/org/openqa/selenium/grid/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,12 @@ public Executable configure(PrintStream out, PrintStream err, String... args) {

outWriter.write("\nFor each command, run with `--help` for command-specific help\n");
outWriter.write(
"\nUse the `--ext` flag before the command name to specify an additional "
+ "classpath to use with the server (for example, to provide additional "
+ "commands, or to provide additional driver implementations). For example:\n");
"""

Use the `--ext` flag before the command name to specify an additional \
classpath to use with the server (for example, to provide additional \
commands, or to provide additional driver implementations). For example:
""");
outWriter.write(
String.format(
"%n java -jar selenium.jar --ext example.jar%sdir standalone --port 1234",
Expand Down
16 changes: 9 additions & 7 deletions java/src/org/openqa/selenium/grid/node/config/NodeFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,15 @@ public class NodeFlags implements HasRoles {
name = "driver-configuration",
prefixed = true,
example =
"\n"
+ "display-name = \"Firefox Nightly\"\n"
+ "webdriver-executable = \"/usr/local/bin/geckodriver\"\n"
+ "max-sessions = 2\n"
+ "stereotype = \"{\\\"browserName\\\": \\\"firefox\\\", \\\"browserVersion\\\":"
+ " \\\"86\\\", \\\"moz:firefoxOptions\\\": {\\\"binary\\\":\\\"/Applications/Firefox"
+ " Nightly.app/Contents/MacOS/firefox\\\"}}\"")
"""

display-name = "Firefox Nightly"
webdriver-executable = "/usr/local/bin/geckodriver"
max-sessions = 2
stereotype = "{\\"browserName\\": \\"firefox\\", \\"browserVersion\\":\
\\"86\\", \\"moz:firefoxOptions\\": {\\"binary\\":\\"/Applications/Firefox\
Nightly.app/Contents/MacOS/firefox\\"}}\"\
""")
public List<String> driverConfiguration;

@Parameter(
Expand Down
10 changes: 6 additions & 4 deletions java/src/org/openqa/selenium/grid/node/relay/RelayFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ public class RelayFlags implements HasRoles {
name = "configs",
prefixed = true,
example =
"\n"
+ "max-sessions = 2\n"
+ "stereotype = \"{\\\"browserName\\\": \\\"safari\\\", \\\"platformName\\\":"
+ " \\\"iOS\\\", \\\"appium:platformVersion\\\": \\\"14.5\\\" }}\"")
"""

max-sessions = 2
stereotype = "{\\"browserName\\": \\"safari\\", \\"platformName\\":\
\\"iOS\\", \\"appium:platformVersion\\": \\"14.5\\" }}\"\
""")
public List<String> driverConfiguration;

@Parameter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ public JdbcSessionMapOptions(Config config) {
}
} catch (NoSuchElementException e) {
throw new JdbcException(
"Missing session options. Check and add all the following options \n "
+ "--jdbc-url <url> \n --jdbc-user <user> \n --jdbc-password <password>");
"""
Missing session options. Check and add all the following options\s
\
--jdbc-url <url>\s
--jdbc-user <user>\s
--jdbc-password <password>\
""");
}
}

Expand Down
20 changes: 11 additions & 9 deletions java/src/org/openqa/selenium/remote/Augmenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,17 @@ public WebDriver augment(WebDriver driver) {

if (driver instanceof Decorated<?>) {
LOG.warning(
"Warning: In future versions, passing a decorated driver will no longer be allowed.\n"
+ " Instead, augment the driver first and then use it to created a decorated"
+ " driver.\n"
+ " Explanation: Decorated drivers are not aware of the augmentations applied to"
+ " them. It can lead to expected behavior.\n"
+ " For example, augmenting HasDevTools interface to a decorated driver. \n"
+ " The decorated driver is not aware that after augmentation it is an instance of"
+ " HasDevTools. So it does not invoke the close() method of the underlying"
+ " websocket, potentially causing a memory leak. ");
"""
Warning: In future versions, passing a decorated driver will no longer be allowed.
Instead, augment the driver first and then use it to created a decorated\
driver.
Explanation: Decorated drivers are not aware of the augmentations applied to\
them. It can lead to expected behavior.
For example, augmenting HasDevTools interface to a decorated driver.\s
The decorated driver is not aware that after augmentation it is an instance of\
HasDevTools. So it does not invoke the close() method of the underlying\
websocket, potentially causing a memory leak.\s\
""");
}

Capabilities caps = ImmutableCapabilities.copyOf(((HasCapabilities) driver).getCapabilities());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,11 @@ public W3CHttpCommandCodec() {

case GET_PAGE_SOURCE:
return toScript(
"var source = document.documentElement.outerHTML; \n"
+ "if (!source) { source = new XMLSerializer().serializeToString(document); }\n"
+ "return source;");
"""
var source = document.documentElement.outerHTML;\s
if (!source) { source = new XMLSerializer().serializeToString(document); }
return source;\
""");

case CLEAR_LOCAL_STORAGE:
return toScript("localStorage.clear()");
Expand Down Expand Up @@ -327,15 +329,17 @@ public W3CHttpCommandCodec() {
}
case SUBMIT_ELEMENT:
return toScript(
"/* submitForm */var form = arguments[0];\n"
+ "while (form.nodeName != \"FORM\" && form.parentNode) {\n"
+ " form = form.parentNode;\n"
+ "}\n"
+ "if (!form) { throw Error('Unable to find containing form element'); }\n"
+ "if (!form.ownerDocument) { throw Error('Unable to find owning document'); }\n"
+ "var e = form.ownerDocument.createEvent('Event');\n"
+ "e.initEvent('submit', true, true);\n"
+ "if (form.dispatchEvent(e)) { HTMLFormElement.prototype.submit.call(form) }\n",
"""
/* submitForm */var form = arguments[0];
while (form.nodeName != "FORM" && form.parentNode) {
form = form.parentNode;
}
if (!form) { throw Error('Unable to find containing form element'); }
if (!form.ownerDocument) { throw Error('Unable to find owning document'); }
var e = form.ownerDocument.createEvent('Event');
e.initEvent('submit', true, true);
if (form.dispatchEvent(e)) { HTMLFormElement.prototype.submit.call(form) }
""",
asElement(parameters.get("id")));

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ void noErrorNoCry() {
@Test
void shouldBeAbleToHandleGatewayTimeoutError() {
String responseString =
"<html>\r\n"
+ "<body>\r\n"
+ "<h1>504 Gateway Time-out</h1>\r\n"
+ "The server didn't respond in time.\r\n"
+ "</body>\r\n"
+ "</html>";
"""
<html>\r
<body>\r
<h1>504 Gateway Time-out</h1>\r
The server didn't respond in time.\r
</body>\r
</html>\
""";

byte[] contents = responseString.getBytes(UTF_8);

Expand All @@ -85,13 +87,15 @@ void shouldBeAbleToHandleGatewayTimeoutError() {
@Test
void shouldBeAbleToHandleBadGatewayError() {
String responseString =
"<html>\r\n"
+ "<head><title>502 Bad Gateway</title></head>\r\n"
+ "<body>\r\n"
+ "<center><h1>502 Bad Gateway</h1></center>\r\n"
+ "<hr><center>nginx</center>\r\n"
+ "</body>\r\n"
+ "</html>";
"""
<html>\r
<head><title>502 Bad Gateway</title></head>\r
<body>\r
<center><h1>502 Bad Gateway</h1></center>\r
<hr><center>nginx</center>\r
</body>\r
</html>\
""";

byte[] contents = responseString.getBytes(UTF_8);

Expand Down