-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LongClick does not seem to work #313
Comments
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 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!
The text was updated successfully, but these errors were encountered: