.Displayed in C# throws when browser-testing on Android 8.0.0 via Appium 1.9.1

Hi Folks,

Greetings from a newbie around here!

This code works fine against Chrome in local (i.e. on PC)…

IWebElement widget = Driver.FindElements(widgetLocator).FirstOrDefault(x => x.Displayed);

…but throws the following when used against Appium 1.9.1 to talk to Android 8.0.0:

OpenQA.Selenium.WebDriverException: 'An unknown server-side error occurred while processing the command. Original error: unknown error: Argument to isShown must be of type Element (Session info: chrome=73.0.3683.90) (Driver info: chromedriver=2.44.609538

The browser does start up on Android, navigates to the page within our site that it’s supposed to, and in most ways works fine. But .Displayed always throws the above without further explanation.

Has anyone else seen this?

I’ve tried using ExecuteJavaScript() to check visibility the hard way, but in OpenQA.Selenium ExecuteJavaScript() returns void, not bool as on other platforms. I’ve tried .Enabled but that doesn’t do what I was after. I’ve borrowed a colleague’s IsElementVisible() function as below, but that throws as well:

   public static bool IsElementVisible(IWebDriver driver, By locator)
        WebDriverWait wait = new WebDriverWait(driver,System.TimeSpan.FromMinutes(1));
        WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromMinutes(1));
        catch (Exception ex)
            return false;
        return true;

And finally I’ve tried to FindElement on the element I’m looking for via CssSelector, ClassName and anything else I could think of, without success (they can’t reliably only find the “visible” version of the element).

By way of background, what I’m trying to do here is to “port” some existing test scripts that work against Chrome on PC via WebDriver to test the same website on Android via Appium. This legacy code uses .Displayed in many places and if I can’t find a reliable alternative in the mobile situation we’ll have somewhat of a problem.

I can’t believe I’m the only one who’s ever seen this, but Google has not been my friend in finding a solution :wink:

All wisdom welcome,
Daryl Hutchings

  1. Use the most recent Appium version
  2. The full server log is needed

Upgrading to Appium WebDriver made the problem go away. Thanks!