Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Adding a LaunchApp command to Chrome specific webdriver client. #168

Closed
wants to merge 16 commits into
from

Conversation

Projects
None yet
8 participants

Adding a LaunchApp command for the Chrome specific Java/Python webdriver clients, which is supported by chromedriver 2.9 and above. Many of our users use the client code here, and this will make it easier for Chrome app developers be able to test their apps using chromedriver.

Member

AutomatedTester commented Feb 27, 2014

From the Python side this looks ok but I wonder if the command file should be a third party dependency since this is specific to the way that Chrome works.

Your thoughts @jleyba ?

@jleyba jleyba and 1 other commented on an outdated diff Feb 27, 2014

...org/openqa/selenium/chrome/ChromeCommandExecutor.java
@@ -38,18 +43,33 @@
private final ChromeDriverService service;
+ private final static Map<String, CommandInfo> chromeCommandsNameToUrl = ImmutableMap.of(
@jleyba

jleyba Feb 27, 2014

Contributor
  • Correct modifier order is static final
  • Use CHROME_COMMAND_NAME_TO_URL for the name as this is an immutable class constant.
  • Move this above the definition of the service field.
@richardrb

richardrb Feb 27, 2014

Done for the points above.

@jleyba jleyba and 1 other commented on an outdated diff Feb 27, 2014

...org/openqa/selenium/chrome/ChromeCommandExecutor.java
this.service = service;
}
+ /**
+ * Creates a new ChromeCommandExecutor which will communicate with the chromedriver as configured
+ * by the given {@code service}.
+ *
+ * @param service The ChromeDriverService to send commands to.
+ */
+ public ChromeCommandExecutor(URL serviceUrl) {
@jleyba

jleyba Feb 27, 2014

Contributor

Why did you add this constructor?

@richardrb

richardrb Feb 27, 2014

I added this constructor to support the case where the chromedriver server is running independently of the client, and we don't want to manage it here in client code.

@jleyba jleyba and 1 other commented on an outdated diff Feb 27, 2014

...c/org/openqa/selenium/chrome/ChromeDriverCommand.java
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package org.openqa.selenium.chrome;
+
+import org.openqa.selenium.remote.DriverCommand;
+
+public interface ChromeDriverCommand extends DriverCommand {
+ String LAUNCH_APP = "launchApp";
@jleyba

jleyba Feb 27, 2014

Contributor

I know this is how DriverCommand is defined, but it's an anti-pattern we shouldn't use. Please change this to

final class ChromeDriverCommand {
  private ChromeDriverCommand(){}

  static final String LAUNCH_APP = "chromium.launchApp";
}
@richardrb

richardrb Feb 27, 2014

Done, but I still need to reference the strings in DriverCommand, so I have this class implement it.

@AutomatedTester I'd prefer to keep it there, it looks other browsers have specific implementations so it would be consistent with that (ie, firefox, opera, etc... directories). If you feel strongly about it I can put it over in third_party.

@jleyba Thanks for the review! I made changes based on your comments, please take another look when you have a chance.

@lukeis lukeis and 1 other commented on an outdated diff Mar 3, 2014

...c/org/openqa/selenium/chrome/ChromeDriverCommand.java
@@ -0,0 +1,26 @@
+/*
+Copyright 2014 Selenium committers
@lukeis

lukeis Mar 3, 2014

Owner

the copyright should just be:
Copyright 2014 Software Freedom Conservancy

(remove the Selenium committers and Google reference)

@richardrb

richardrb Mar 3, 2014

Done. For here and the other files added.

Owner

lukeis commented Mar 3, 2014

I don't necessarily agree with putting it in third party, almost makes more sense for chromedriver to release another python package to pypi for users to also grab, since this falls under the section of browser specific extensions to the protocol. @shs96c input appreciated.

Hmm, I think it would be really helpful to end users to have this available in Selenium over having to download another package, in many cases users probably won't know this is available. There's already a hacky way to launch apps through the UI, so including this in Selenium will encourage users to do something better.

Member

AutomatedTester commented Mar 14, 2014

Sorry for not replying sooner.

I agree that yet another download is not useful. I suggest raising this on
the Selenium Developers mailing list. We at Mozilla have a similar
situation.

David

David Burns
Email: david.burns@theautomatedtester.co.uk
URL: http://www.theautomatedtester.co.uk/

On Thu, Mar 6, 2014 at 7:32 PM, richardrb notifications@github.com wrote:

Hmm, I think it would be really helpful to end users to have this
available in Selenium over having to download another package, in many
cases users probably won't know this is available. There's already a hacky
way to launch apps through the UI, so including this in Selenium will
encourage users to do something better.

Reply to this email directly or view it on GitHubhttps://github.com/SeleniumHQ/selenium/pull/168#issuecomment-36926943
.

alanpca commented May 22, 2014

@richardrb do you have any example specs which make use of this?

Contributor

bayandin commented Oct 20, 2014

Any updates? @AutomatedTester?
I want to add PerformanceLog feature and I want to do it the same way.

Member

AutomatedTester commented Oct 20, 2014

There is a discussion on https://groups.google.com/forum/m/#!topic/selenium-developers/-GS1wyTH2aI about this that has gone dead, I suggest posting there for an update


Sent from Mailbox

On Mon, Oct 20, 2014 at 5:23 PM, Alexander Bayandin
notifications@github.com wrote:

Any updates? @AutomatedTester?

I want to add PerformanceLog feature and I want to do it the same way.

Reply to this email directly or view it on GitHub:
#168 (comment)

@andreastt andreastt commented on the diff Mar 2, 2015

py/selenium/webdriver/remote/webdriver.py
@@ -62,7 +63,7 @@ def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub',
proxy.add_to_capabilities(desired_capabilities)
self.command_executor = command_executor
if type(self.command_executor) is bytes or type(self.command_executor) is str:
- self.command_executor = RemoteConnection(command_executor, keep_alive=keep_alive)
+ self.command_executor = remote_connection_client(command_executor, keep_alive=keep_alive)
@andreastt

andreastt Mar 2, 2015

Owner

I can't see that the symbol remote_connection_client is defined here.

@sevaseva

sevaseva Apr 24, 2015

Contributor

One of the commits in the PR added remote_connection_client parameter to this constructor. However that change is unnecessary and everything in this file needs to be reverted. (I'll add comments in chrome/webdriver.py explaining how)

@andreastt andreastt commented on the diff Mar 2, 2015

py/selenium/webdriver/chrome/command.py
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from selenium.webdriver.remote.command import Command
+
+class ChromeCommand(Command):
+ """
+ Defines Chrome specific commands while including standard WebDriver ones.
+ """
+ LAUNCH_APP = "launchApp"
@andreastt

andreastt Mar 2, 2015

Owner

Enums isn't really a thing in Python. Please just embed the "launchApp" string in chrome/webdriver.py.

Owner

andreastt commented Mar 2, 2015

@richardrb, this change looks mostly good to me. Can you make the few changes requested and rebase? Sorry it's taken so long to get around to.

@AutomatedTester, I can't load the link you posted. If it's dead, should we close this?

Member

AutomatedTester commented Mar 15, 2015

As discussed in https://groups.google.com/forum/m/#!topic/selenium-developers/-GS1wyTH2aI we are going to close this and this will need to be released separately by the Chromium Project

p.s. I don't necessarily agree with this so suggest bringing it up in that email thread.

Contributor

sevaseva commented Apr 22, 2015

@shs96c @lukeis @andreastt @AutomatedTester

Some 20 days ago there was a post that suggested that how to implement vendor specific commands in the client bindings and where to put those client bindings' code are two separate questions. It didn't generate a lot of stir, fair enough.

If there is anyone who is actively against reopening and merging [1] this PR or against the proposal in the post (which is basically the same thing), can you please reply there or here?

While a decision about the place for vendor specific client code is being made in the other thread I see no reason to block changes in that code.

In fact, IEDriver and FirefoxDriver, ChromeDriver and possibly other vendor specific client side changes went in just fine recently. (phantomjs specific #475 almost made it in, too)

[1] After fixing issues including @andreastt suggestions and reverting unnecessary changes in core files webdriver/remote/webdriver.py and selenium/remote/HttpCommandExecutor.java.

Contributor

sevaseva commented Apr 24, 2015

Well, maybe there's no one who is actively again this anymore. Let's reopen, make last adjustments and merge this.

@richardrb , can you please

If any of these changes you don't know how or don't have time to do, let me know and I may do them; I'd make sure this change would still go in attributed to you even if I need to make adjustments before pushing.

@sevaseva sevaseva reopened this Apr 24, 2015

@sevaseva sevaseva commented on the diff Apr 24, 2015

py/selenium/webdriver/chrome/webdriver.py
@@ -61,6 +63,7 @@ def __init__(self, executable_path="chromedriver", port=0,
try:
RemoteWebDriver.__init__(self,
command_executor=self.service.service_url,
+ remote_connection_client=ChromeRemoteConnection,
@sevaseva

sevaseva Apr 24, 2015

Contributor

remote_connection_client parameter is unnecessary, it should not be passed here and reverted from remote/webdriver.py.

What you need to do is to pass an instance of ChromeRemoteConnection as a value of command_executor parameter.

See the current latest revision for an updated documentation that should make this less confusing:

- command_executor - Either a string representing URL of the remote server or a custom

@sevaseva sevaseva commented on the diff Apr 24, 2015

...org/openqa/selenium/chrome/ChromeCommandExecutor.java
@@ -36,20 +41,35 @@
*/
class ChromeCommandExecutor extends HttpCommandExecutor {
+ private static final Map<String, CommandInfo> CHROME_COMMANDS_NAME_TO_URL = ImmutableMap.of(
+ ChromeDriverCommand.LAUNCH_APP,
+ post("/session/:sessionId/chromium/launch_app"));
@sevaseva

sevaseva Apr 24, 2015

Contributor

Please simply use constructor, new CommandInfo(), instead of method post()

@sevaseva sevaseva commented on the diff Apr 24, 2015

...c/org/openqa/selenium/remote/HttpCommandExecutor.java
@@ -496,15 +496,15 @@ private Response createResponse(HttpResponse httpResponse, HttpContext context,
return response;
}
- private static CommandInfo get(String url) {
+ protected static CommandInfo get(String url) {
@sevaseva

sevaseva Apr 24, 2015

Contributor

I suggest we revert all changes in this file. They are not necessary. Other classes that already create instances of CommandInfo outside of this class simply use CommandInfo constructor(s), we could keep doing the same here.

@sevaseva sevaseva commented on the diff Apr 24, 2015

...c/org/openqa/selenium/chrome/ChromeDriverCommand.java
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package org.openqa.selenium.chrome;
+
+import org.openqa.selenium.remote.DriverCommand;
+
+final class ChromeDriverCommand implements DriverCommand {
@sevaseva

sevaseva Apr 24, 2015

Contributor

I don't really see how this class/enum helps anything, especially while it is is declared with package-private access. I suggest reverting this class and simply using string literal "chromium.launchApp" in one place where it's used.

Contributor

sevaseva commented May 8, 2015

Lack of response from PR author.
After May 18 I should have a chance to address the comments and push a cleaned version of this.

@sevaseva sevaseva self-assigned this Aug 6, 2015

sevaseva added a commit that referenced this pull request Aug 6, 2015

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

sevaseva added a commit that referenced this pull request Aug 6, 2015

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

sevaseva added a commit that referenced this pull request Aug 6, 2015

JavaScript client side support for launch_app command of chromedriver:
/session/$sessionId/chromium/launch_app
This is related to pull request #168

@sevaseva sevaseva closed this Aug 6, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment