Click on a button not on the screen?

Hello,
I am working on a test system and I have a question.
I saw that we can find all the Hierarchy of a page (including element outside the screen, like ‘Battery’ on this example):


Is it possible to click on the button Battery ( and access to the battery menu) without scrolling down?

I think you must swipe down until the element you want to click is finded.

Keep in mind that the Appium driver is capable of getting the entire page hierarchy even if it’s not visible, that works for a validation action but for a clicking action the element must be visible.

i.e. in the iPhone sprinboard you can see all the elements (Apps) no matter how many pages you have.

ok thanks, I hoped it could be possible.

I’m trying to do t with SwipeWhileNotFound(Direction, Offset, SwipeTime, ElementToFind, Delay, Rounds, Click) , but I don’t really understand how the “offset” works.

What is a “validation action”?

offset mean the distance (in pixels) from the border where the swipe action starts.

if you set a Swipe UP with an offset of 200, the action starts 200px from the top border.

validation action: check if an item exists in the current page/screen

[edit to specify that the distance is in pixels)

Ok thank you, and can I recover and save a value with a validation action ? ( for example the battery level on my own app) or is it the same as a click on a button ?

If you want to retrieve the string that contains the battery power percentage, you can use the command:

FindElement and GetText(Element)
String text1 = driver.findElement(By.xpath("")).getText();

Yes but the name and the value change in function of the battery level, how can I make my “findElement” ?

In the screenshot I added you can see that the battery (from the settings screen) has the property knownSuperClass = UIStatusBarBatteryItemView. This should give you a lead on how to find the element. You should aim for a unique and static property to find the element, after which you will be able to extract the text.