In latest APPIUM
I found that driver.scrollTo(“testing”) method is
deprecated. How can I perform scrollTo action using new way of doing
it? Please help.
From the documentation, I can see, we need to use MobileBy.ByAndroidUIAutomator . But, I’m not really sure how to use this .
1 Like
Hi,
I’m new to Appium, not able to understand this function. Any documentation to go through before using this function. Please help.
Thanks,
Bharath
Is there the same for the ruby version?
You can make your own scroll actions using the existing swipe method like this
def swipeFrom(startText, stopText) @startCords = wait{find(startText).location} @endCords = wait{find(stopText).location} swipe(start_x:@startCords[0],start_y:@startCords[1],end_x:@endCords[0],end_y:@endCords[1], duration:3000) end
1 Like
This would help you: How to get the co-ordinates to scroll up and down
Instead of native scroll method which takes text (not an element), I used this method to swipe to the element.
But if you want to scroll down to an element is because the element maybe isn’t in the screen, so the @endCords will not be find…
Am I right?
Ah right. Well there may be a better way to do this but I made a swipeDown method that goes like
def swipeDown
@x = window_size[:width]/2
@y = window_size[:height] - 200
@startCords = [@x,@y]
@endCords = first_text.location
swipe(start_x:@startCords[0],start_y:@startCords[1],end_x:@endCords[0],end_y:@endCords[1], duration:3000)
end`
and then I made a swipeToFindMethod
def swipe_to_find(textParam)
for i in 0..3
begin
if wait{find(textParam).displayed?} == true
return true
end
rescue
swipeDown
end
end
end
You can change the for loop to however many times you want, but you don’t want it to keep searching forever
1 Like
I’m thinking in another way, however yet to try.
Get the page source before swipe down. Save the page source in a variable.
Swipe down once and again get the page source. Compare the current page source with the saved one. If both matches, you are in the end of the page.
Any thoughts?
@email2vimalraj :
If the element is in the middle of the page maybe this isn’t fair.
You could pass one element (swipe method is so imprecise with ms in real devices) and never find the page source saved
@slipy12 : Sorry if I understand you correctly.
Find the element in the page, if not then perform swipe. Repeat this until you find an element or fail the test case in case you reached the end of the page without finding element as mentioned earlier.
Correct me if I am wrong.
Yes, yes, what I was saying is that you have to take care about which duration parameter you set because in real devices the swipe isn’t regular (sometimes is a little one, sometimes is larger), it depends of the cpu performance or memory load.
Is a good way to perform the swipe_to(element)
Got you and agree with you @slipy12
Try this :
MobileElement radioGroup = (MobileElement) wd
.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()"
".resourceId(\"+listview_id+\")).scrollIntoView("
"new UiSelector().text(\"+your_text+\"));");
radioGroup.click();
This link will help you : https://www.youtube.com/watch?v=bT3tqaLNn-Y
1 Like
scrollTo() method has been deprecated.
So for the Android Native app, we can perform scroll with the UiScrollable and UiSelector classes.
Method 1:
String DESTINATION_ELEMENT_TEXT= "KUBO"; ((AndroidDriver) driver).findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()) .scrollIntoView(new UiSelector().text(DESTINATION_ELEMENT_TEXT))");
Method 2:
String APP_SCROLLVIEW = "android.widget.ScrollView"; String DESTINATION_ELEMENT_TEXT= "KUBO"; ((AndroidDriver) driver).findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().className(APP_SCROLLVIEW)) .scrollIntoView(new UiSelector().text(DESTINATION_ELEMENT_TEXT))");
2 Likes
Android Python Swipe operation with condition to check if the element is there or not.
The below function continues to look for the locator till its found. It will repeatedly do swipe down & check for id (15 times)
Works perfectly for my android native app.
def android_is_visible(self, locator):
for _ in xrange(15):
x = 1000
try:
value = self.get_element(locator).is_displayed()
if value is True:
break
except NoSuchElementException:
self.driver.swipe(470, 1400, 470, x, 400)
self.driver.implicitly_wait(5)
continue
email2vimalraj:
d agree
Going to try this tomorrow
rini
July 31, 2017, 10:07am
19
Hi @sridhareaswaran
can you please help me out
anori_Takaki
one issue i faced that in this application
that it is accepting my inputs from purpose of call and selecting the field
dr.findElement(By.id(“iv_poc”)).click();
dr.findElement(By.id(“radio_button”)).click();
but then we need to scroll page becuase we need to fill the response of call field .
once i scroll the page it is not taking inputs!
dr.swipe(0, 0, 50, 20, 100);
dr.findElement(By.id("iv_roc")).click();
dr.findElement(By.id("radio_button")).click();
and my code is this , from green line is showing propose of call
rini
July 31, 2017, 10:19am
20
and i am using java language over here