Hi @Benoit,
Yes. If the cell has certain property that can be compared before and after click then you can use that and then make a call to scrollTo again.
Thanks,
Sujata
Hi @Benoit,
Yes. If the cell has certain property that can be compared before and after click then you can use that and then make a call to scrollTo again.
Thanks,
Sujata
Hey @sujata_kalluri,
I can detect my cell, but now is not displayed, is there any change to scrollTo an element?
I tried something like that :
IOSElement logoutElement = (IOSElement)driver.findElementByAccessibilityId(LOGOUT_KEY);
if (!logoutElement.isDisplayed()) {
((IOSDriver)driver).scrollTo(logoutElement.getText());
}
But it doesnât work at all.
In my case I do not want to give a string because the app can be localised, or text can be updated. I really want have something automatic.
Thanks,
Ben
â EDIT â
The only way I found is to detect a cell that is already displayed and swipe down from it to get access to my cell. Itâs working but itâs not a good idea if I change the cell order or anything else.
I did that with swipe(SwipeElementDirection.DOWN, 1000);
which take a millisec param (good to know because itâs not in the documentation) and had to contains between 0.5sec and 60sec.
Hope it gonna help someone else.
To work around the scrolling issues on iOS, Iâve resorted to using javascript. Iâm sure there are better (and less ugly) ways to do this, but hereâs my solution in Ruby:
def scroll(scrollable, element)
driver.execute_script("if (document.readyState === 'complete'){document.querySelector('#{scrollable}').scrollTop = 0;}")
px = element.location.y - element.size.height - 100
driver.execute_script("if (document.readyState === 'complete'){document.querySelector('#{scrollable}').scrollTop = #{px};}")
end
The variable âscrollableâ is the scrollable element on the page (likely the background div or something) and âelementâ is the element youâre trying to scroll to.
The reason it scrolls to the top of the page before scrolling to the correct position is because scrollTop doesnât scroll by a number of pixels, it scrolls to a pixel position, so âscrollTop = 600â will always scroll down (or up) to the 600 px position. âelement.locationâ on the other hand tells you how far from your current position on the page the element is. Scrolling to the top every time just made everything so much easier.
Hi @sujata_kalluri,
Not really since then. Iâll keep my solution for now, waiting for something easier to use and maintain.
Thanks,
Ben
Hi all ,
there is a solution that worked for me .
MobileElement element = (MobileElement)testCaseObj.getDriverFactory().getAppiumDriver().findElement(By.
xpath(âYOUR ELEMENTS XPATHâ));
JavascriptExecutor js = (JavascriptExecutor) testCaseObj.getDriverFactory().getAppiumDriver();
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put(âdirectionâ, âdownâ);
scrollObject.put(âelementâ, (element).getId());
js.executeScript(âmobile: scrollâ, scrollObject);
}
Convert your WebElement to MobileElement and then perform the scroll.(One will have to import MobileElement class)
Appium fails to scroll at TableView and CollectionView . Appium can easily scroll on ScrollView.
Hope the solution might be a help.
Hi guys,
For people trying to scroll into UITableView to click to a given UITableViewCell, there is no need to use scrollTo method.
Iâve just tried to click on a IOSElement, giving the accessibilityLabel of my UITableViewCell, without checking if the cell is displayed or not. It automatically scroll to the element if itâs present and clic on it. My mistake was to make something more complicated that it was.
Thanks for your help,
Ben
Hi,
Thank you for the solution. As I wasted more than a week for this and finally found. There are few modifications to be made
It Has the Simple solution buddyâŚ
WebElement parentElem = driver.findElement(MobileBy.xpath("//UIATableView[1]"));
((IOSElement) parentElem).scrollTo(âStringâ);
Regrds
**[quote=âMobile_Test_Test, post:6, topic:4220, full:trueâ]
@bhaskar @sujata_kalluri
Guys could you put some focus on this?
[/quote]
**
with appium 1.8.2, java-client.There is no scrollTo method for iOS driver.So is there any other way to perform scroll with a tableView for a specific cell?Thanks
with appium 1.8.2,java-client.There is no scrollTo method at all for ios element.So is there other way to perform scrollTo? My requirement is scroll to a specific cell on a tableView;