Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for Appium Chrome Dev Protocol Commands #1375

Merged

Conversation

jayandran-Sampath
Copy link
Contributor

Change list

Client integration for Appium Chrome browser CDP Command support. Enable user to use chrome dev tool protocol commands in appium java client

new Endpoint : /session/:sessionId/goog/cdp/execute

Types of changes

What types of changes are you proposing/introducing to Java client?
Put an x in the boxes that apply

  • No changes in production code.
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Details

Code Sample

Example 1 : Without Parameters
driver.executeCdpCommand("Page.getCookies")

Example 2 : With Parameters
Map<String,Object> params = new HashMap();
params.put("latitude", 13.0827);
params.put("longitude",80.2707);
params.put("accuracy",1);
driver.executeCdpCommand("Emulation.setGeolocationOverride",params);

default Map<String,Object> executeCdpCommand(String command, @Nullable Map<String, Object> params) {
Map<String, Object> data = new HashMap<>();
data.put("cmd",checkNotNull(command));
if(params != null){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please auto format all files, so spaces are set properly everywhere

data.put("params",params);
}
Response response = execute(EXECUTE_CDP_COMMAND, data);
Map<String, Object> value = (Map<String, Object>) response.getValue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need in the intermediate value variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid warning of Unchecked cast, Im continuing with the same representation but will be changing to return as Immutable map

data.put("params",params);
}else{
params = new HashMap<>();
data.put("params",params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data.put("params", params == null ? Collections.emptyMap() : params)

@@ -69,7 +69,7 @@
@SuppressWarnings("unchecked")
public class AppiumDriver<T extends WebElement>
extends DefaultGenericMobileDriver<T> implements ComparesImages, FindsByImage<T>, FindsByCustom<T>,
ExecutesDriverScript, LogsEvents, HasSettings {
ExecutesDriverScript, LogsEvents, HasSettings,ExecuteCDPCommand {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature is currently only present in AndroidDriver

@@ -282,6 +284,7 @@
commandRepository.put(COMPARE_IMAGES, postC("/session/:sessionId/appium/compare_images"));
commandRepository.put(EXECUTE_DRIVER_SCRIPT, postC("/session/:sessionId/appium/execute_driver"));
commandRepository.put(GET_ALLSESSION, getC("/sessions"));
commandRepository.put(EXECUTE_CDP_COMMAND, postC("/session/:sessionId/goog/cdp/execute"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the vendor name is configurable. Please rename the constant to EXECUTE_GOOGLE_CDP_COMMAND

@jayandran-Sampath
Copy link
Contributor Author

@mykola-mokhnach Will update the review comments and commit it again

@jayandran-Sampath jayandran-Sampath changed the title Client support for Appium : Chrome Dev Protocol feat: Support for Appium Chrome Dev Protocol Commands Jul 23, 2020
@SrinivasanTarget SrinivasanTarget merged commit c33b577 into appium:master Jul 23, 2020
@jayandran-Sampath jayandran-Sampath deleted the chromeDevToolsSupport branch July 23, 2020 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants