-
-
Notifications
You must be signed in to change notification settings - Fork 59
Description
The problem
Unable to locate element on Real Device post switching to webview of a hybrid app.
Environment
Appium version : 1.22.2
Desktop OS/version used to run Appium: Windows 10 Android Version 10
Node.js version : v16.13.1
Npm or Yarn package manager: 8.1.2
Mobile platform/version under test: Android 10
Real device : Galaxy M20
Appium CLI or Appium.app|exe: Appium CLI
Chromedriver on Real Device used: 98.0.4758.48
Chromedriver on Emulator used: 83.0.4103.106
Links to chromedriver Logs
Chromedriver getpagesource() response logs on emulator. https://gist.github.com/Rahul1970/97f8e8fd0a5f1145873a237855ba33c1.js
Chromedriver getpagesource() response logs on real device.
https://gist.github.com/Rahul1970/bf078ac294e534b7749f5e33493bd110.js
Link to Appium logs
1..Appium logs for working code on emulator on successful switch context to webview and able to locate element.
https://gist.github.com/Rahul1970/c503aa9943cf60649a7fed269f5b5797.js
2. Appium logs on real device on successful switch context to webview but not able to locate element.
https://gist.github.com/Rahul1970/585e3c08718ec291bf2b0c4452af89b3.js
Details
In my hybrid mobile application on real device i am able to pass through the native views but when landing on webview and able to switch to webview i am not able to locate element. I am able to locate elements on webview in emulator but not able to do so on real device.
Code To Reproduce Issue [ Good To Have ]
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);//deviceName
dc.setCapability(MobileCapabilityType.UDID, deviceName );
//dc.setCapability(MobileCapabilityType.PLATFORM_VERSION,platformVersion);
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
dc.setCapability(MobileCapabilityType.APP, System.getProperty("user.dir")+"/src/test/resources/apps/"+AppName);
dc.setCapability("automationName","UiAutomator2");
dc.setCapability("unicodeKeyboard", true);
dc.setCapability("resetKeyboard", true);
dc.setCapability("autoWebview", false);
//dc.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
//dc.setCapability("appWaitForLaunch", false);
dc.setCapability("appPackage", "com.crmnextmobile.crmnextofflineplay");
dc.setCapability("appActivity", "com.crmnextmobile.crmnextofflineplay.qr.QrScannerActivity");
driver = new AndroidDriver(service.getUrl(),dc);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
ReUsableMethods.mobileStartRecording();
login();
ReUsableMethods.clickElement(sp.itemMenu," Menu Summary Page ");
ReUsableMethods.clickElement(lp.leadMenu,"Lead Menu Page");
ReUsableMethods.clickElement(lp.addLead,"Lead Add icon");
ReUsableMethods.clickElement(lp.addNewLead,"Add new lead");
Set contextNames = ((SupportsContextSwitching)driver).getContextHandles();
for (String contextName : contextNames)
{
System.out.println("Available Context"+contextName);
}
System.out.println("Before Context Switch"); ////Switching context to webview
((SupportsContextSwitching) driver).context("WEBVIEW_com.crmnextmobile.crmnextofflineplay");
System.out.println("After Context Switch");
Thread.sleep(10000);
ReUsableMethods.mobileStartRecording();
ReUsableMethods.enterText(lp.shortName,Leads[0], "shortname is entered.");
System.out.println(" Context Switched");
Thread.sleep(4000);
Hi Team Any help in this direction would be very helpful.