Java-client: Android: Cannot call non W3C standard command while in W3C mode

Created on 25 Sep 2019  路  21Comments  路  Source: appium/java-client

The problem

On trying to create a new android session, i am seeing this message after the session gets created.
Unknown command: Cannot call non W3C standard command while in W3C mode

I don't see this issue if i remove the capability:
dc.setCapability(MobileCapabilityType.AUTO_WEBVIEW, true);

Switiching to webview works if i use driver.setContext() and i do not see W3C error.
But the error is seen with doesn't work with AutoWebview.

I am using java client 7.2.0 in this process

Environment

  • Appium version (or git revision) that exhibits the issue: v1.15.0-beta.1
  • Node.js version (unless using Appium.app|exe): v10.16.2
  • Npm or Yarn package manager: 6.9.0
  • Mobile platform/version under test: 7.0
  • Real device or emulator/simulator: Moto G4
  • Java Client : 7.2.0

Details

Desired capabilities:

            DesiredCapabilities dc = new DesiredCapabilities();
            if(aut.equalsIgnoreCase("android")){
                dc.setCapability(MobileCapabilityType.DEVICE_NAME, "Moto G4");
                dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
                dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.0");
                dc.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 500);
                dc.setCapability(MobileCapabilityType.APP, System.getProperty("user.dir")+"/app/xxx.apk");
                dc.setCapability(MobileCapabilityType.AUTO_WEBVIEW, true);
                dc.setCapability(MobileCapabilityType.FORCE_MJSONWP, true);
                dc.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, true);
                dc.setCapability(AndroidMobileCapabilityType.SUPPORTS_ALERTS,true);
                driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), dc);
            }

Link to Appium logs

https://gist.github.com/mayureshshirodkar/cf37d78bbdb847457914d667a3ada519

Most helpful comment

@roddymunro Wow, so complicated. How about

capabilities.setCapability("appium:chromeOptions", ImmutableMap.of("w3c", false));

All 21 comments

This is the bug of java client, which is fixed in the recent master, but is not published yet

Thanks @mykola-mokhnach

For anyone facing this issue. I have resolved it by using latest changes from the master branch of java client.

Using Maven:

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

        <dependency>
            <groupId>com.github.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>master-SNAPSHOT</version>
        </dependency>

Is there an ETA on when the fix will be published?

@mykola-mokhnach so what is the resolution as of today?

Either use java client from master or enforce chromedriver to work in jsonwp mode

So when I am trying to update the java client snapshot to master, I am getting the below errors while trying to compile the code

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/sroy107/git/CSAF/framework-core/src/main/java/com/comcast/utils/PageCore.java:[1473,33] cannot find symbol
symbol: method filter(java.util.logging.Level)
location: class org.openqa.selenium.logging.LogEntries
[ERROR] /Users/sroy107/git/CSAF/framework-core/src/main/java/com/comcast/uilocator/MobileObjRepoLocator.java:[130,114] cannot access org.openqa.selenium.internal.HasIdentity
class file for org.openqa.selenium.internal.HasIdentity not found
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

@mykola-mokhnach I am still waititng for the work around for now. As i mentioned above, if I am updating the dependency with master, the existing code is throwing compilation errors.

Sp i tried to update the following capability
MobileCapabilityType.FORCE_MJSONWP, true but it is also thwrowing the same error "Cannot call non W3C standard command while in W3C mode"

@Sourabh25 does this work for you?

   <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

        <dependency>
            <groupId>com.github.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>master-SNAPSHOT</version>
        </dependency>

@mayureshshirodkar no.

I am getting error class org.openqa.selenium.logging.LogEntries
and
org.openqa.selenium.internal.HasIdentity
class file for org.openqa.selenium.internal.HasIdentity not found

The only way we were able to work around this issue was by modifying the chromedriver source code for the latest chrome version, and building it ourselves. We then had to turn W3C mode off in the Chrome Options.

There was a code change between Chromedriver 75 and 76 which was the course for these issues. Reverting that block of code to the 75 version, and doing the above worked for us...

@roddymunro Wow, so complicated. How about

capabilities.setCapability("appium:chromeOptions", ImmutableMap.of("w3c", false));

@mykola-mokhnach i updated my pom to refer to master

com.github.appium
java-client
master-SNAPSHOT

I also set the w3c to false.
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("clearSystemFiles", true);
capabilities.setCapability("platformName", platformName);
capabilities.setCapability("deviceName", deviceName);
capabilities.setCapability("platformVersion", platformVersion);
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Chrome");
capabilities.setCapability("w3c", true);
String broweserDir;
if(osName.contains("mac")) {
broweserDir = TestUtils.getRelativePath()+File.separator + "src/main/resources/BrowserSpecificDrivers/chromedriver";
}else {
broweserDir = TestUtils.getRelativePath()+File.separator + "src/main/resources/BrowserSpecificDrivers/chromedriver.exe";
}

But I am still getting the error
Cannot call non W3C standard command while in W3C mode

This worked for me with ChromeDriver 76:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("w3c", false);
capabilities.merge(chromeOptions);
driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

@mykola-mokhnach @benken-parasoft my bad. I need to add it to the chromeoptions. It is working... thanks for all the help

@roddymunro Wow, so complicated. How about

capabilities.setCapability("appium:chromeOptions", ImmutableMap.of("w3c", false));

don't forget to set capability.setCapability("newCommandTimeout", 0); in code else appium will close session after default time (60 sec).

@roddymunro Wow, so complicated. How about

capabilities.setCapability("appium:chromeOptions", ImmutableMap.of("w3c", false));

This worked for me (Y)

Hi @mykola-mokhnach does the recently released java client 7.3.0 have this fix?

Workaround in Python:
self.desired_caps["chromeOptions"] = {"w3c": False}

@roddymunro Wow, so complicated. How about

capabilities.setCapability("appium:chromeOptions", ImmutableMap.of("w3c", false));

This work for me too. Thanks @roddymunro

@roddymunro Wow, so complicated. How about

capabilities.setCapability("appium:chromeOptions", ImmutableMap.of("w3c", false));

This work for me too. Thanks @roddymunro

it works for me ..thnks.

Was this page helpful?
0 / 5 - 0 ratings