Open dah-fari7009 opened 2 years ago
Update: I went around this by using swipe(steps=100) instead
since you have reopened this i will give you some code for scrolling with uiautomator
import uiautomator2 as u2
def scroll_screen(device, direction='down', steps=10, duration=0.1):
"""
Scrolls the screen in the specified direction for a given number of steps.
Args:
device (uiautomator2.Device): The device object to interact with.
direction (str): The direction to scroll ('down', 'up', 'left', 'right'). Defaults to 'down'.
steps (int): The number of scroll steps to perform. Defaults to 10.
duration (float): The duration of each swipe in seconds. Defaults to 0.1.
"""
# Get the device's screen size
width, height = device.window_size()
# Define start and end coordinates based on direction
coords = {
'down': (width // 2, height * 3 // 4, width // 2, height // 4),
'up': (width // 2, height // 4, width // 2, height * 3 // 4),
'left': (width * 3 // 4, height // 2, width // 4, height // 2),
'right': (width // 4, height // 2, width * 3 // 4, height // 2)
}
start_x, start_y, end_x, end_y = coords.get(direction, coords['down'])
# Perform the scroll action for the specified number of steps
for _ in range(steps):
device.swipe(start_x, start_y, end_x, end_y, duration=duration)
print(f"Scrolled {direction} step {_ + 1}/{steps}")
# Example usage:
device = u2.connect()
scroll_screen(device, direction='down', steps=10, duration=0.1)
Hi,
I am using uiautomator to explore an Android app programmatically ( org.liberty.android.fantastischmemo)
I am trying to perform a long click on a ListView to make a context menu visible, however it seems a click a list view item is performed instead. No context menu shows up and it moves to the next screen (which happens when clicking on a menu item) Here's the code I am using:
After the long click, the app transitions from to
instead of
Thank you!