1
votes

My test consist of having a list of element. Clicking on the first one to open it then swipe right to left to access the next one and make sure that they are different.

On Android it's working perfectly but for some reason it seems that the driver doesn't refresh itself after swiping into the new page.

If i'm trying to access a text i keep on having the element from the first page even if i'm in the 2nd or 3rd element of the list

is there a sort of refresh page in Appium iOS ?

here is my code :

finding my title

driver.findElement(By.id("title_label"));

swiping

Dimension size = driver.manage().window().getSize();
driver.swipe(size.getWidth()-100, size.getHeight()/2, 100, size.getHeight()/2, 500);

then remake the find title function and even tough me screen is changing on my ipad and a can see the new title, in the code I still have the old one

any idea ?

Edit :

Just to be clear if it wasn't. This is happening when swiping to a new page so the whole page is refreshing. It's not just a part of it or swiping inside an element of the same page.

1
Could you check what you get when you print out the contents of driver.getPageSource() after the swipe? Perhaps there are two elements with id "title_label" first being the original one you already found? - Lasse
have you take the element again after swipe? - noor
@Domestus it seems that it keeps the old page in memory somwhere and i have access to 2 titles instead of 1 and since the method i'm using is findElement i just get the 1st one but if I use findElements I get the 2 titles & the 2nd one is the correct one ... What an ios crap ... - user3718160
If both of them exist, it's because of how the UI has been coded in the app itself. If getPageSource() shows both, it probably means that both elements exist, even if other one is hidden. You might want to check if you can make the second findElement() statement based on some of the attributes listed in getPageSource. For example xpath query with 2 checks: findElement(By.xpath("//UIAElement[@name='title_label'][@attribute='true']")); Otherwise try to fix the app UI behavior. - Lasse

1 Answers

0
votes

Try to get the location as getLocation() and then you can implement swipe or scroll in all directions using:

 TouchAction action = new TouchAction(driver);

            int startY = element1.getLocation().getY() + (element1.getSize().getHeight() / 2);
            int startX = element1.getLocation().getX() + (element1.getSize().getWidth() / 2);

            int endX = element2.getLocation().getX() + (element2.getSize().getWidth() / 2);
            int endY = element2.getLocation().getY() + (element2.getSize().getHeight() / 2);

            action.press(startX, startY).waitAction(2000).moveTo(endX, endY).release().perform();