How to scroll up and down in robotium in single line code - robotium

How we can scroll up and down in android apk using robotium .I want some simple code like we use in the Webdriver to navigate back which is a single line code.
Is there any single line code to scroll up and down.

The solo object has a scrollDown() and scrollUp() method available on it.

For scrolling down : solo.scrollViewToSide(yourView, Solo.DOWN);
For scrolling up : solo.scrollViewToSide(yourView, Solo.UP);

Related

Locate elements inside WebView

I'm trying to automate a test with detox. The app under test is implemented using react-native but we have a screen that renders a WebView that load an url. In this case, I cannot use the accessibilityLabel or testID in order to access the elements displayed inside the WebView. Anyone know if there is a way to locate elements inside a WebView with detox?
There is currently no way to do so https://github.com/wix/detox/issues/665
A work around could be done by using this but if running on different screen sizes the test would probably fail https://github.com/wix/detox/issues/334#issuecomment-335802212
It's finally possible to interact with webview elements in Detox (only Android currently).
Check out this link

How to replace react-native FlatlList indicator

I have write custom header in FlatList.
Now I want to replace the indicator with other picture both in Android and ios.
I have try many way to modify it, but all Failed.
here is my demo code https://github.com/kk412027247/react-native-custom-flatlist

React Native | text highlighting

I am working on a react native app.
in one page of it I wan't to make a highlighting option like the following picture
but I can't customize the text popover to reach this behavior,
after many trials I reached the following result
Any idea how to add highlighting functionality?
Try using react-native-highlight-words library . Might be it solves your problem
Just use a webview and use the injectedJavaScript prop

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.

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.