This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
15 / 15
May 2018

Hey There people!

Is there any method, on which we can scroll to particular element in python without using coordinates.
I have used everything but all goes useless…

  • created

    Feb '18
  • last reply

    May '18
  • 14

    replies

  • 4.1k

    views

  • 5

    users

  • 1

    like

  • 4

    links

Can you try this for iOS:

el = self.driver.find_element_by_id('locator_id')
self.driver.execute_script('mobile: scroll', {"element": el, "toVisible": True})

Hey @Venkatesh_Akula I have tried it. But its not.Its showing "Element not Found."
Because element is not within view, we have to go down in order to click that element.

Refer to this issue thread which has specifically mentioned about python client as well.

I suggest all to start watching appium project in github, lots of learnings and interesting discussion happens there.

@VikramVI you need to look title of discussion again…
Its “EXCEPT FROM COORDINATES”.
Whole topic is on coordinates and nothing. So your answer didn’t helped.

This is not working on Android, can some one please provide for Android.

Tried Below:

    self.desired_caps = {}
    self.desired_caps['platformName'] = 'Android'
    self.desired_caps['platformVersion'] = '8.0.0'
    self.desired_caps['deviceName'] = '23fbda3d'
    #self.desired_caps['deviceName'] = device_id
    self.desired_caps['fullReset'] = 'false'
    self.desired_caps['noReset'] = 'true'
    self.desired_caps['appPackage'] = 'com.whatsapp'
    self.desired_caps['appActivity'] = 'com.whatsapp.HomeActivity'
    self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)

Appium Version:V1.7.2

Logic:
self.driver.find_element_by_xpath("//android.widget.TextView[@text=‘CALLS’]").click()
self.driver.find_element_by_xpath("//android.widget.ImageView[@resource-id=‘com.whatsapp:id/fab’]").click()

    self.driver.find_element_by_xpath("//android.widget.ImageView[@content-desc='More options']").click()
    time.sleep(3)
    self.driver.find_element_by_xpath("//android.widget.TextView[@text='Contacts']").click()
    time.sleep(3)
    element_to_tap = self.driver.find_element_by_xpath("//android.widget.TextView[@text='Fire']")
    element_to_drag_to=self.driver.find_element_by_xpath("//android.widget.TextView[@text='Maruti']")
   self.driver.scroll(element_to_drag_to, element_to_tap)

Please help in this.

I have tried this as well.
This logic is also not working.

Can I Assume that there is no scrolling method in python for appium?

yes ,even i am also not able to scroll .Witing for the reply

Hi Taimoor,

Check this solution using “uiautomator”,This worked for me.

self.driver.find_element_by_android_uiautomator(
“new UiScrollable(new UiSelector()).scrollIntoView(element(”\value"));").click()

Ex:
self.driver.find_element_by_android_uiautomator(
“new UiScrollable(new UiSelector()).scrollIntoView(text(“Ramu”));”).click()

Hey @ramu

I have tried this and pycharm is throwing me this exception.

selenium.common.exceptions.InvalidSelectorException: Message: invalid selector (Locator Strategy ‘-android uiautomator’ is not supported for this session)

:frowning:
Guys there must be some way.

3 months later

Element1 = driver.find_element_by_xpath(‘Source Xpath’)
Element2 = driver.find_element_by_xpath(‘Destination Xpath’)

driver.scroll(Element1, Element2)