I am running appium 1.3.7 on an android application over a 4.3 device, i have encountred a problem when using findElement function. I want to test it on a List, the elements i want to find are visible. Appium doesn’t scroll to find these elements so the test fails, but when i scroll the list manually, appium detects them and the test passes.
@sam_viz Yes its normal if you want to perform some action like click the element should be visible for capturing property or getting elements count its not a problem it can capture the properties for the elements which are not even in the visible region
@NishantSingh Thank you for your answer. I don’t think it captures the properties because Appium actually fails to detect the element, i have the following logs:
The weird symbols are normal because i am trying to find a name in french.
If the element have any unique “resourceId” property please use that as you are using “name” property to find it and name contains this weird symbol which can be a prob. and if still you want to use name property then check whether the copied name is same or not. Once I also worked for french site for desktop sites and sometime when we copy the symbol it gets changed So please check that
@NishantSingh I tought the problem would come from some encoding issue but it isn’t, i tried the same search (By.name) on another element which is in the visible area of the device and it worked. So i don’t think it’s related to that.
I only can work with name, because infortunately all the cells in the list have the same resourceId… So the only option left is for me to work with name search.
Do you have some Suggestions?
Thank you for your answer tough.
no sure but maybe in Android also. anyway normalization greatly helps. we just created our compare strings function with normalization of text to avoid any such problems.
I am more than aware that normalization of text can avoid a lot of problems, but in my case, the problem is that appium don’t detect elements which are outside of the visible area of the device. I just tried on some normal text without any french accent, and the problem is still the same…
I just tried out using MobileBy, but it didn’t work …
I tought it would come frome using the By.name so i tried with By.xpath, and again it is working on all the elements which are in the visible area, but as soon as i try to fetch and element out of this area, i get the following error:
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"Could not find an element using supplied strategy. "},"sessionId":"33ed715d-a54d-49d8-97b4-4b4abb8763b7"}
with Android elements outside screen are not available to Appium.
with iOS elements outside can be available to Appium but you can’t tap on them.
So if you have some list of elements with Android and you are searching for some element you need to Scroll/Swipe list of elements to make not visible elements of list available.
This is exactly the answer i wanted. Thank you !
Is there a way to scroll to a certain point of the screen? i just read the scrollTo function and it only accepts a string as the name of some element. And this is something i want to avoid…
with Android wrote own function scrollbyElementToSomeDirection.
with function we have Element (normally this is some element where list or elements are. in your case it is “//android.widget.ExpandableListView/android.widget.RelativeLayout[10]”) and direction as variables. inside function it is taking given element position and making swipe to needed direction.
e.g. resulting function:
((AppiumDriver) driver).swipe(startPoint.x , StartPoint.y, EndPoint.x, EndPoint.y, duration);
Thanks for the shared infos, appreciate it !
For the moment tough, i think i am going with the names, and externalise all the strings in an extern class.
Have a nice a day.
Thank you all for your answers.
Bro use this “driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);” it will sure work. You have to just make the script wait for few seconds to open the app on emulator or device and then run the script. just include that 1 line of code and you are good to go