Skip to content

Commit b0fbed0

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

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
from selenium.webdriver.remote.remote_connection import RemoteConnection
19+
20+
class ChromeRemoteConnection(RemoteConnection):
21+
22+
def __init__(self, remote_server_addr, keep_alive=True):
23+
RemoteConnection.__init__(self, remote_server_addr, keep_alive)
24+
self._commands["launchApp"] = ('POST',
25+
'/session/$sessionId/chromium/launch_app')

py/selenium/webdriver/chrome/webdriver.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717

1818
import base64
19+
from remote_connection import ChromeRemoteConnection
1920
from selenium.webdriver.remote.command import Command
2021
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
2122
from selenium.common.exceptions import WebDriverException
@@ -61,14 +62,18 @@ def __init__(self, executable_path="chromedriver", port=0,
6162

6263
try:
6364
RemoteWebDriver.__init__(self,
64-
command_executor=self.service.service_url,
65-
desired_capabilities=desired_capabilities,
66-
keep_alive=True)
65+
command_executor=ChromeRemoteConnection(
66+
remote_server_addr=self.service.service_url),
67+
desired_capabilities=desired_capabilities)
6768
except:
6869
self.quit()
6970
raise
7071
self._is_remote = False
7172

73+
def launch_app(self, id):
74+
"""Launches Chrome app specified by id."""
75+
return self.execute("launchApp", {'id': id})
76+
7277
def quit(self):
7378
"""
7479
Closes the browser and shuts down the ChromeDriver executable

0 commit comments

Comments
 (0)