java-client icon indicating copy to clipboard operation
java-client copied to clipboard

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

Open mayureshshirodkar opened this issue 7 years ago • 24 comments

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

mayureshshirodkar avatar Sep 25 '19 05:09 mayureshshirodkar

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

mykola-mokhnach avatar Sep 25 '19 05:09 mykola-mokhnach

Thanks @mykola-mokhnach

mayureshshirodkar avatar Sep 25 '19 05:09 mayureshshirodkar

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>

mayureshshirodkar avatar Sep 26 '19 04:09 mayureshshirodkar

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

roddymunro avatar Sep 30 '19 08:09 roddymunro

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

Sourabh25 avatar Oct 04 '19 20:10 Sourabh25

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

mykola-mokhnach avatar Oct 04 '19 20:10 mykola-mokhnach

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

Sourabh25 avatar Oct 04 '19 21:10 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"

Sourabh25 avatar Oct 07 '19 14:10 Sourabh25

@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 avatar Oct 07 '19 14:10 mayureshshirodkar

@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

Sourabh25 avatar Oct 07 '19 14:10 Sourabh25

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 avatar Oct 07 '19 14:10 roddymunro

@roddymunro Wow, so complicated. How about

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

mykola-mokhnach avatar Oct 07 '19 15:10 mykola-mokhnach

@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

Sourabh25 avatar Oct 07 '19 16:10 Sourabh25

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);

benken-parasoft avatar Oct 07 '19 16:10 benken-parasoft

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

Sourabh25 avatar Oct 07 '19 17:10 Sourabh25

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

vs111 avatar Nov 01 '19 07:11 vs111

@roddymunro Wow, so complicated. How about

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

This worked for me (Y)

hasithawaruna avatar Nov 02 '19 09:11 hasithawaruna

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

oldstone avatar Jan 17 '20 02:01 oldstone

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

rodicaDan avatar Feb 28 '20 14:02 rodicaDan

@roddymunro Wow, so complicated. How about

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

This work for me too. Thanks @roddymunro

ankur1233 avatar Apr 05 '20 17:04 ankur1233