Skip to content

Android: Cannot call non W3C standard command while in W3C mode #1242

Closed

Description

@mayureshshirodkar

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")+"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/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

Activity

  1. mykola-mokhnach commented on Sep 25, 2019

    @mykola-mokhnach
    Contributor

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

  2. mayureshshirodkar commented on Sep 25, 2019

    @mayureshshirodkar
    Author
  3. mayureshshirodkar commented on Sep 26, 2019

    @mayureshshirodkar
    Author

    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>
    
    
  4. roddymunro commented on Sep 30, 2019

    @roddymunro

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

  5. Sourabh25 commented on Oct 4, 2019

    @Sourabh25

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

  6. mykola-mokhnach commented on Oct 4, 2019

    @mykola-mokhnach
    Contributor

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

  7. Sourabh25 commented on Oct 4, 2019

    @Sourabh25

    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] ------------------------------------------------------------------------

  8. Sourabh25 commented on Oct 7, 2019

    @Sourabh25

    @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"

  9. mayureshshirodkar commented on Oct 7, 2019

    @mayureshshirodkar
    Author

    @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>
    
  10. Sourabh25 commented on Oct 7, 2019

    @Sourabh25

    @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

  11. roddymunro commented on Oct 7, 2019

    @roddymunro

    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...

  12. mykola-mokhnach commented on Oct 7, 2019

    @mykola-mokhnach
    Contributor

    @roddymunro Wow, so complicated. How about

    capabilities.setCapability("appium:chromeOptions", ImmutableMap.of("w3c", false));
  13. Sourabh25 commented on Oct 7, 2019

    @Sourabh25

    @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

  14. benken-parasoft commented on Oct 7, 2019

    @benken-parasoft

    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);
    
  15. Sourabh25 commented on Oct 7, 2019

    @Sourabh25

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

  16. vs111 commented on Nov 1, 2019

    @vs111

    @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).

  17. hasithawaruna commented on Nov 2, 2019

    @hasithawaruna

    @roddymunro Wow, so complicated. How about

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

    This worked for me (Y)

  18. oldstone commented on Jan 17, 2020

    @oldstone

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

  19. rodicaDan commented on Feb 28, 2020

    @rodicaDan

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

  20. ankur1233 commented on Apr 5, 2020

    @ankur1233

    @roddymunro Wow, so complicated. How about

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

    This work for me too. Thanks @roddymunro

  21. Kajugul commented on May 28, 2020

    @Kajugul

    @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.

  22. LiorLPerfecto commented on Feb 7, 2021

    @LiorLPerfecto

    Using Android emulator with:
    pixel 4
    Android 11
    Chromdriver 83

    getting error: Cannot call non W3C standard command while in W3C mode
    is there a fix for that ?

    Not happening on android 10

  23. Prashant150397 commented on Oct 27, 2022

    @Prashant150397

    @roddymunro Wow, so complicated. How about

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

    This worked for me........ thanks

  24. trupti-salunkhe commented on Mar 11, 2024

    @trupti-salunkhe

    @roddymunro Thanks it worked for me...
    capabilities.setCapability("appium:chromeOptions", ImmutableMap.of("w3c", false));

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions