Recognizing element in an Hybrid App - Android - selenium

I am new to Android testing. I am currently trying to automate a scenario. I have attached the snapshot of the app screen:
Scenario:
I need to click on "Clock In".
A screen slides from the bottom as shown in the snapshot.
I need to select an item as shown by the arrow.
The developer is saying that it is a Hybrid app. A lot of confusion here for me as I am able to click on "Clock In", but I am not able to select "DL 380 Memory Upgrade".
Doubts:
How to find whether "DL 380 Memory Upgrade" is in Webview/Native?
If it is an element in the webview, how to locate it? I located "CLOCK IN" as below:
#AndroidFindBy(xpath = "//android.view.View[#resource-id='tab-t0-0']")
private AndroidElement clockInTabBtn;

If its an element in WebView, then its web and you won't find anything in web while searching by resource-id - its native attribute only.
I would recommend to use chrome dev tools for debugging hybrid application.
You can read official docs for setup.
Basically you need:
connect device
go to chrome://inspect/#devices in chrome browser
check phone & allow usb debugging if popup appears
check what webViews chrome spotted and click inspect for the one you need
And now you search for elements and their locators the same way you did in Selenum/Web automation
Don't forget to switch context to WebView in your appium test before you actually searching inside webView.
Good luck!

You can check available view using context and can switch to it using follows code:
Set<string> contextNames = driver.getContextHandles();
for (String contextName : contextNames)
{
System.out.println(contextNames);
//To swicth to webview
if (contextName.contains("WEBVIEW")){
driver.context(contextName);
}
}
Please refer this thread for similar issue: https://github.com/appium/appium/issues/7243

Related

Automate a react native Android application using selenium

I'm trying to inspect element on react native app
but unfortunately I could not find any element on it, I have use ui automator viewer and appium inspector.
Can anyone help me please?
I have no problem to inspect react native application with appium desktop, you can check article on Sauce Labs blog with pretty good details and iOS RN app/python example.
It's a bit tricky to uniquely identify UI elements, but still possible with setting unique accessibilityLabel for the View on RN side and search for it with AccessibilityId locator strategy in Appium.
Provide more details in case you need additional help.
Unfortunately, without having accessibilityLabel in Views of RN app, you are limited to use xpath locator and search by element text, like "//android.widget.TextView[contains(text(), 'Skip')]".
Avoid using strict #text= as it might not work for every element ,e.g. if text split in 2 lines on some device.

How to recording current screen(not open popup) and audio by muaz-khan WebRTC-Experiment webrtc

muaz-khan WebRTC-Experiment
How to edit the extension to be as I want
Thanks
No its not possible to do within browser, its the matter of end user privacy.
You can build your own native Windows/Mac application to get rid of this
Chrome is providing screen/window/tab capturing through chooseDesktopMedia API, it is available only from chrome extension and we cant call this API from web app.
That demo extension is showing how to use chooseDesktopMedia.
We have no control on the screen selection popup, we can only choose the
combination of screen/window/tab/audio with the DesktopCaptureSourceType

How to automate native "Search" button in Appium Java

driver.findElementById("SearchField").sendKeys("bacon");
After sending keys the Native Keyboard opens automatically on IOS.
How can i automate Tap on native keyboard "Search"?
Appium + Java + Selenium + Eclipse
If you are using java-client 3.1.0, you can use this:
((AndroidDriver) driver).sendKeyEvent(AndroidKeyCode.ENTER);
Assuming you are automating a native mobile application. then you can easily click on the search button.
driver.findElement(By.Xpath("xpath of search icon")).click();
If you are automating web application then you need to change your context to native like below.
STEPS
Get the current context handles
Save the current context Context to Native
Change the Context to Native
Click on the search button
change the context to default
CODE
driver.getContextHandles();
String currentContext = driver.getContext();
driver.context("NATIVE_APP");
driver.findElement(By.Xpath("xpath of search icon")).click();
driver.context(currentContext);
Not sure if this would be helpful for you since it's been half a year but I did have a similar problem. If I was going to search with "Bruno Mars" in the search field, I would just have appium type in "Bruno Mars\n" and the newline would automatically trigger the search button. However, recently my devices weren't responding to the new line anymore. I winded up downgrading the google keyboard to 4.1.x and I was able to use new line method again. The problem was that the devices had auto updated to to version 5.x. So downgrading the keyboard solved the issue for me.

Verifying toasts using Appium , and get server reaction to button clicks

i'm new to android automation testing and i recently started to work with Appium.
I use it for android native app automation.
I have 2 question -
is there a way to verify toasts?
the latest posts i saw which referred to this issue are from the mid of 2014
and i wanted to know if there's something new in this subject before i will find another tool to run my tests with (as i understand selendroid can verify toasts).
is there a way to catch the http request which my app sends to the server when i'm pressing a button, during the automatic test?
something like a listener which works in the backround and wait for clicks?
tnx
To verify toast messages you can use one of image recognition libraries. For ruby I use RTesseract together with image processor RMgick
Idea is simple:
make toast message to appear
take few screenshots
iterate over taken screenshots and look for text
You may play with image processing, to increase recognition quality.
Here you can find code snippet which I use in my framework: link

how to navigate to settings in android emulator using robotium?

I am a newbie for Robotium and till then I managed to learn a lot by directly writing test cases for public websites and sorted out several issues from answers in stackoverflow. now, I seemed to hit the wall at this (probably)trivial problem.
I would like to navigate to 'Settings' icon which is inside 'Apps' menu of the android emulator using some sort of 'robotium-solo' method.
This is my failed attempt:
solo.sendKey(KeyEvent.KEYCODE_HOME);
//solo.clickOnImageButton(2); // no success!
//solo.clickOnActionBarItem(2); // no success!
solo.clickOnText("Settings");
solo.clickOnText("Music");
I checked for any KEYCODE_var for home screen 'app' icon but couldn't find one.
There is no useful log message in DDMS to figure out the starting activity when clicked/tapped on that button.s
Please guide me whether my approach is any good and help me with an answer. Thanks.
you can check with getCurrentViews() and have the list of views displayed before clicking the menu button and after clicking the menu button.By comparing them you can get the view of the new views displayed (i.e. settings button).
After getting the view,you can go with solo.clickOnView(ViewNameObtained);
This will solve your problem for sure.
As far as I know, navigating to settings is not possible with robotium. Even if you would be able to go there you cannot perform any other action as Settings are not port of your application. Android Instrumentation allows performing actions only within one package and robotium is only wrapper for that, so it's not able to click outside your application as well.
You can use UI Automator for that.