Find and run Element not on the screen

Hi !

I found something interesting, with the method .findElement(…) I can find something not on the screen ( but on the same page of the app) without swipe up/down, I can also get the tesxt of the element with .gettext, but I can’t “click” on it to go on the menu, someone have an idea about how to go on the menu ( like with .click()) when the element is found but not on the screen?

1 Like

The explanation is that you can see the entire page structure nevertheless if is visible or not (out off the screen bonds) BUT you can only interact (click, drag…) with elements that are inside the bonds of the screen (if you can see it, you can click)

So you must swipe until the element is visible to you, then click over it.

is it exists something to create a fast function, like “swipe until this element is on the screen”?

in Seetest this function exist but on AppiumStudio isn’t implemented.

As a workaround, you can make a loop where looking for the element and swiping, if the element is found exit loop and do the desired action

somthing like this (C# code):

while(1==1)
{
    driver.ExecuteScript("client:client.swipe(\"Down\", 30, 500)");
    if(driver.FindElementByXPath(itemXPath)
        break;
}

// Do action here

messing with the offset of the swipe (2nd parameter with a value of 30) you can control the amount of scrolling.

Appium Studio’s implementation of this command doesn’t require a while loop. Also, the use of a while loop is a bit dangerous, especially one in which the condition is always true.

To swipe in order to find element not on the screen:

String str1 = (String)driver.executeScript("client:client.swipeWhileNotFound(\"DIRECTION\",OFFSET, SWIPE TIME, \"ELEMENT\", DELAY, ROUNDS, CLICK)");

For example:
String str1 = (String)driver.executeScript("client:client.swipeWhileNotFound(\"Up\", 0, 2000, \"xpath=//*[@text='user']\", 1000, 5, true)");

1 Like

of course Nivi’s solution is more elegant :grinning:

Is it possible to have a complete list of executeScripts actions available to AppiumStudio? it seems to be very similar to Seetest actions

1 Like

I don’t understand why, but it doesn’t work for my (no errors on the consol, but nothing happen)

I myself is also having issue encountered by HelloWorld such that even the button element is not on the screen, swipeWhileNotFound is able to find it but clicking on the button failed because it is not on the screen. As a result, I have not choice but to use the While loop.

Tested on Samsung Galaxy A5 real device.

Is it a known issue?

Hi guys,

Sorry for only reporting back now.

@mateoaqx they are based on SeeTest commands. You can find the list here.

@HelloWorld and @cwchan,
There seems to be an issue with this command. You can go with mateo’s while loop solution for now. I’ll update once I know more about this issue.

1 Like