0

I am trying to scroll in an Android App but I'm getting an error.

Code :

Dictionary<string, string> scrollObject = new Dictionary<string, string>();
scrollObject.Add("direction", "down");
((IJavaScriptExecutor)driver).ExecuteScript("mobile: scroll", scrollObject);

Error: System.NotImplementedException: Method has not yet been implemented
 at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Appium.AppiumDriver`1.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScriptCommand(String script, String commandName, Object[] args)
   at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScript(String script, Object[] args)
   at AppiumTesting2.Program.Main(String[] args)
2
  • Are you trying to just scroll down or to an element? Also are you using iOS Simulator for iOS 7 or 8?
    – kirbycope
    Commented May 30, 2017 at 19:22
  • Hello kirbycop, I'm can either scroll to an element or just scroll down to half the page. I'm using a real Android device with Nougat 7.1.1. Commented May 31, 2017 at 6:17

1 Answer 1

1

The Swipe, ScrollTo, and ScrollToExact methods have been deprecated. The 2.0.0.1 release notes suggests using OpenQA.Selenium.Appium.ByAndroidUIAutomator or OpenQA.Selenium.Appium.ByIosUIAutomation. Here is their example:

[Test]
public void ScrollingToSubElement()
{
    driver.FindElementByAccessibilityId("Views").Click();
    AndroidElement list = driver.FindElement(By.Id("android:id/list"));
    var locator = new ByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("
                    + "new UiSelector().text(\"Radio Group\"));");
    AppiumWebElement radioGroup = list.FindElement(locator);
    Assert.NotNull(radioGroup.Location);
}

As an alternative, a different approach (which is similar to the one you were trying) is presented on SO.

WebElement element = driver.findElementByXpath("xpath_of_element");
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.