Skip to content

Commit 1b6febd

Browse files
committed
Java client side support for launch_app command of chromedriver:
/session/$sessionId/chromium/launch_app This is using the approach proposed by @richardrb in pull request #168
1 parent 9114480 commit 1b6febd

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

java/client/src/org/openqa/selenium/chrome/ChromeDriver.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.openqa.selenium.chrome;
2020

21+
import com.google.common.collect.ImmutableMap;
2122
import org.openqa.selenium.Capabilities;
2223
import org.openqa.selenium.WebDriver;
2324
import org.openqa.selenium.WebDriverException;
@@ -30,7 +31,6 @@
3031
import org.openqa.selenium.remote.RemoteWebDriver;
3132
import org.openqa.selenium.remote.html5.RemoteLocationContext;
3233
import org.openqa.selenium.remote.html5.RemoteWebStorage;
33-
import org.openqa.selenium.remote.service.DriverCommandExecutor;
3434

3535
/**
3636
* A {@link WebDriver} implementation that controls a Chrome browser running on the local machine.
@@ -167,7 +167,7 @@ public ChromeDriver(ChromeDriverService service, ChromeOptions options) {
167167
* @param capabilities The capabilities required from the ChromeDriver.
168168
*/
169169
public ChromeDriver(ChromeDriverService service, Capabilities capabilities) {
170-
super(new DriverCommandExecutor(service), capabilities);
170+
super(new ChromeDriverCommandExecutor(service), capabilities);
171171
locationContext = new RemoteLocationContext(getExecuteMethod());
172172
webStorage = new RemoteWebStorage(getExecuteMethod());
173173
}
@@ -198,4 +198,11 @@ public Location location() {
198198
public void setLocation(Location location) {
199199
locationContext.setLocation(location);
200200
}
201+
202+
/**
203+
* Launches Chome app specified by id.
204+
*/
205+
public void launchApp(String id) {
206+
execute(ChromeDriverCommand.LAUNCH_APP, ImmutableMap.of("id", id));
207+
}
201208
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.chrome;
19+
20+
/**
21+
* Constants for the ChromeDriver specific command IDs.
22+
*/
23+
final class ChromeDriverCommand {
24+
private ChromeDriverCommand() {}
25+
26+
static final String LAUNCH_APP = "launchApp";
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.chrome;
19+
20+
import com.google.common.collect.ImmutableMap;
21+
22+
import org.openqa.selenium.remote.CommandInfo;
23+
import org.openqa.selenium.remote.http.HttpMethod;
24+
25+
import org.openqa.selenium.remote.service.DriverCommandExecutor;
26+
import org.openqa.selenium.remote.service.DriverService;
27+
28+
import java.util.Map;
29+
30+
/**
31+
* {@link DriverCommandExecutor} that understands ChromeDriver specific commands.
32+
*/
33+
class ChromeDriverCommandExecutor extends DriverCommandExecutor {
34+
35+
private static final Map<String, CommandInfo> CHROME_COMMAND_NAME_TO_URL = ImmutableMap.of(
36+
ChromeDriverCommand.LAUNCH_APP,
37+
new CommandInfo("/session/:sessionId/chromium/launch_app", HttpMethod.POST));
38+
39+
public ChromeDriverCommandExecutor(DriverService service) {
40+
super(service, CHROME_COMMAND_NAME_TO_URL);
41+
}
42+
}

0 commit comments

Comments
 (0)