I am automating an android app.I want to take screenshot of the screen in android app by placing an element to a specific coordinate by scrolling/swiping. How can I do so??
use below code will help you :
driver.find_element_by_android_uiautomator('new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("**/Put some text of scroll screen/**").instance(0))')
driver.save_screenshot("screenshot.png")
below is my sample code to scroll & take screenshot, I am facing any issue:
from appium import webdriver
class test123():
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4.2'
desired_caps['deviceName'] = 'XXXXXX'
desired_caps['appPackage'] = 'net.one97.paytm'
desired_caps['appActivity'] = 'net.one97.paytm.AJRJarvisSplash'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.implicitly_wait(1000)
driver.find_element_by_id('net.one97.paytm:id/edit_no').send_keys("9999990088")
driver.find_element_by_id('net.one97.paytm:id/lyt_mob_op').click()
driver.find_element_by_android_uiautomator(
'new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("Vodafone").instance(0))').click()
driver.save_screenshot("screenshot.png")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.