Issue automating Cordova application using Appium - android

We have a Cordova mobile application designed for Android platform. When we use Appium Inspector to inspect element properties we do not see either resource-id or content-desc for different elements. Could anyone please help in getting locators for these elements? Or is there anything that has to be taken care during application build time for getting any identifiers?
Attaching screenshot from Appium Inspector Window and Page Source for the page for reference.
Thanks in advance for any help!
Appium Version: 1.2.3
Java Client : 2.0.0
Page Source:
enter image description here

Finally I was able to resolve the issue, when WebView was exposed for the application. And I could inspect element properties on different screens on the mobile application.
The developers enabled this view. If anyone else is also struggling with this issue.
Please make sure you contact your developers and ask them to enable WebView for mobile application.

Related

Unable to inspect PICKER/DROPDOWN on Appium Inspector(Android)

Device: Android
App: react native hybrid app
Appium/Appium Inspector version: Version 1.15.1 (1.15.1.20191013.2)
Issue:
I am unable to inspect a picker/dropdown. It doesn't appear in the app source at all. Hence unable to find any locators to do further automation.
Description:
I open the android app on the mobile and navigate to a form where
certain details need to be filled.One of the things to be filled is
a dropdown.
I click on the arrow on the dropdown field
A NEW window/popup appears on top of the ORIGINAL form for the
picker values to be displayed, which can be scrolled to see various
values.
This new picker value window/pop up doesnt not come in the app
source in the appium inspector at all
Can you please tell me a workaround to automate this scenario to select values in the dropdown.I am using Java + Selenium + Appium for the automation framework .
Thank you!
I hope you have used uiautomatorviewer to inspect the element on Android App. Can you please check on uiautomatorviewer if not done already.

Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist! ",displaying for app with dynamic locators

I have the app with dynamic elements and unable to get screenshot for my app error is showing
Error while obtaining UI hierarchy XML file:
com.android.ddmlib.SyncException: Remote object doesn't exist!
for other apps UI Automator viewer is working fine.
Please suggest any other tool to get apps locator or any other way? I have stopped Appium and did all the solutions but same issue. UI Automator is working fine for other apps.
Thanks
That's a pretty common issue with UIAutomatorViewer: it fails to take screen snapshot if layout is dynamicly changing, works fine for static ones.
If you use Appium and Android device with OS 6+ it is not relevant to use UIAuyomatorViewer for elements inspection, as Appium uses UiAutomator2 and element structure may differ.
Use appium-desktop instead.
Please use appium inspector for desktop. It will help you to locate the elements.
Please visit here for more info.
Thanks!!!

How to locate elements in mobile app ? (findElement By class, id)

i am learning automation testing with mobile applications.
When i had gone through some tutorials i found that we can locate elements using UIAutomator Viewer-- by taking screenshot and finding elements.
But by taking screenshot i could not find elements of some elements.
So, do we have any other ways to find elements or any other tools like UIAutomator?
Please help.
If u have any good links for mobile automation testing please do forward.
Thanks.
UIAutomator is provided by Android SDK and this is part of Android tools.
You can use the tool that provided by Appium. Please see details and example here
Generally, Install UI automator incase you are using appium in windows, if your using mac, you can identify using appium inspector.
find_element(class: "classname")
find_element(id: "resource-id name")
if you want to click on them add .click
find_element(class: "classname").click
If your still not having the details of id , text , content-desc, you can choose to add xpath
Go through this link for more info.
If you are part of testing team, testing on the app being developed, You may raise a bug to the developer in case, there are no unique identifiers and ask the dev team to add one.
When you are trying to find elements using UIautomatorviewer, you need to highlight the element which you want to find the locator.
If it's not giving you either id, name or xpath then you have to write
xpath manually. For writing xpaths manually refer these link1 and link2.
As another option, you can use appium desktop client to find the elements in the mobile app. For that you need to follow the below steps,
1. In appium window, click on 'Start Inspector Session' icon
2. In there you need to add the relevant capabilities there.
refer the image here.
desiredCapabilities.setCapability("app", "C:\\Users\\VWEERAY\\Desktop\\APPIUM\\mediashare.apk");
desiredCapabilities.setCapability("appPackage", "com.android.chrome");
desiredCapabilities.setCapability("appActivity", "org.chromium.chrome.browser.document.ChromeLauncherActivity");
desiredCapabilities.setCapability("platformName", "Android");
desiredCapabilities.setCapability("deviceName", "192.168.56.101:5555");
desiredCapabilities.setCapability("deviceName", "AndroidDevice1:5554");
desiredCapabilities.setCapability("platformVersion", "6.0");
3.Then click on 'Start Session' in the bottom.
4. It will open with a Mobile view and from there you can find locators like in the uiautomatorviewer.

How to use selectors in Mobile App using Appium

I am trying to inspect an Android/iOS app .
When i inspect an android app, I get the following:-
resource-id: com.company.droid.qa:id/textNewsDate
class:- android.widget.TextView
package:- com.company.droid.qa
Will package name will be added in resource-id across all ids in app ?
For Some element, i did't see the text only see the id. Can i know why ?
Using: UIAutomatorViewer to inspect an android app
Is there any better tool to inspect an android/ios app in linux machine?
UIAutomator is good to find the locator of an element. The reason you don't see text/ID for some elements because your developers didn't add it for that element. You can ask your developer to modify it as per your need.

How to determine the XPATH of Android UI elements. Selenium + Appium

I am currently working on automating an android application using Appium and Selenium and have run into some problems with locating elements by ID. I want to use XPATH but do not know how to get the XPATH of android UI elements. Does anyone know how to determine the XPATH of an element or know of a tool that can do this work quickly? Thanks!
You can use android sdk tool - uiautomatorviewer( https://developer.android.com/tools/testing/testing_ui.html) it's like appium inspector, but work better for me.
com.android2.calculator3:id/digit8
For Elements with id
driver.findElement(By.id("com.example.testapp:id/txtLogin"))
For Elements with class
android.widget.EditText[#index=0]
Syntax
{ClassName}[#{anyAttributeName}={valueOfAttribute}]
Code
driver.findElements(By.className("android.widget.EditText"));//will return ARRAY
There is a way you can figure out the xpath. First get the page source from the application. This will be in xml format. Then copy the source to a xpath tester website like xpath tester. Then create the xpath and check if it works. This is assuming you already know how to create xpaths.
Appium's client comes with an Inspector tool!
This will tell you the xpath of whatever element you're interested in
Try viewing the source code:
https://android.stackexchange.com/questions/5039/how-do-i-view-source-in-the-android-browser
Then figuring out the xpath becomes easier from there.
You can use UIAutomatorviewer utility in Android SDK to get the required locator. Go to your Android SDK installation's 'tools' folder and trigger uiautomatorviewer.bat file. From there, you can locate app elements.
Visit this link which shows how to use it.
http://www.testingdiaries.com/locate-android-app-elements/
Enable developer options in your phone and Connect your phone and invoke the chrome inspector for android devices( type -- about:inspect in chrome ) your device will be displayed.
Just click on the Inspect button & the screen in mobile will be displayed.
You are provided with the application and the complete DOM structure.. Make your own XPATH from that.
You could use it like this:
WebElement btn_yes = driver.findElement(By.xpath("//android.widget.Button[#text='Yes']"));

Categories

Resources