appium: Not able to identify elements on Webview using Java

The problem

We have a salesforce app built using react native for iOS and Android. The first screen that shows up on launching app is a WebView with username/password and login button. The activity of this screen is com.salesforce.androidsdk.ui.LoginActivity. Appium is able to successfully install and launch the app but is not able to sendkeys in username field or interact with any other element on the page.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.6.5
  • Last Appium version that did not exhibit the issue (if applicable): NA
  • Desktop OS/version used to run Appium: Mac 10.12.5
  • Node.js version (unless using Appium.app|exe): 6.11.1
  • Mobile platform/version under test: Android 7.1.1
  • Real device or emulator/simulator: Emulator and Real device is Android 6.0.1
  • Appium CLI or Appium.app|exe: CLI

Details

We have a salesforce app built using react native for iOS and Android. The first screen that shows up on launching app is a WebView with username/password and login button. The activity of this screen is com.salesforce.androidsdk.ui.LoginActivity. Appium is able to successfully install and launch the app but is not able to sendkeys in username field or interact with any other element on the page.

Link to Appium logs

https://gist.github.com/jineshqa/2499010a84c347a4aef5b8355a47ebc2

Code To Reproduce Issue [ Good To Have ]

import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;

/**
 * Created by Jinesh on 8/17/17.
 */
public class demoTestCase {

    public static void main(String [] args) throws MalformedURLException {

        File f = new File("app");
        File fs = new File(f,"app-debug.apk");


        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability(MobileCapabilityType.DEVICE_NAME,"DEVICE_NAME");
        cap.setCapability(MobileCapabilityType.APP,fs);
        cap.setCapability("recreateChromeDriverSessions", true);
        cap.setCapability("appPackage","com.xxxx.scanner");
        cap.setCapability("appActivity",".MainActivity");
        cap.setCapability("appWaitActivity","com.salesforce.androidsdk.ui.LoginActivity");
        cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT,"300");
        cap.setCapability("automationName","uiautomator2");

        AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap);

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        driver.context("WEBVIEW_com.xxxx.scanner");

        driver.findElement(By.className("username")).sendKeys("secret");
        driver.findElement(By.id("password")).sendKeys("secret");
        driver.findElement(By.id("Login")).click();
        

    }
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (1 by maintainers)

Most upvoted comments

@SteffyVarghese1 upgrade to latest or downgrade to https://mvnrepository.com/artifact/io.appium/java-client/5.0.4. Try a couple of versions and see. Also, note that for me the first page was Webview and so I had to switch context.

@jlipps @priyankshah217 @pavanbachu0604 Its working after I upgraded from java-client-5.0.0-BETA9.jar to latest.