question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

isDisplayed() error, Method is not implemented. Conditional try catch implementation is not working

See original GitHub issue

The problem

I am trying to check if the element is present or not, so I am using “isDisplayed()” but it gives me “Exception in thread “main” org.openqa.selenium.UnsupportedCommandException: Method is not implemented” error. I checked the other issues most of them are about the client version. I updated all my clients but still gives me the error.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.22.3
  • Desktop OS/version used to run Appium: Windows 10
  • Node.js version (unless using Appium.app|exe): 16.14.0
  • Npm or Yarn package manager: npm 8.16.0
  • Mobile platform/version under test: Android 12
  • Real device or emulator/simulator: Real device
  • Appium CLI or Appium.app|exe: from directly cmd

Details

I also tried with conditions but instead of catches and continues to run, it is just throwing me the error


isElementPresented(By.xpath("blabla"));

 public static boolean isElementPresented(By by){
        try{
            driver.findElement(by);
            System.out.println("store found");
            return true;
        }catch (NoSuchElementException e ){
            System.out.println("store not found");
            return false;
        }
    }

“store found” shows but false condition is not working"

Log of conditional run https://gist.github.com/OnurSerbes/6f0cecae55fdefb722d6f73a009897d8

Link to Appium logs

Appium Log https://gist.github.com/OnurSerbes/ea942168570a938fc5cb0365347d6026

Editor Log https://gist.github.com/OnurSerbes/3ddefe92a95617aa5e64b290f3bbcb1f

Code To Reproduce Issue [ Good To Have ]

if(driver.findElement(By.xpath("blabla")).isDisplayed()){
            WebElement store = driver.findElement(By.xpath("blabla"));
            String storeText = store.getText();
            System.out.println("store: " + storeText);
        }

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mykola-mokhnachcommented, Oct 14, 2022

Probably you have issues understanding the concept of existence/visibility of elements. Try asking at Appium forum about it. You could start at https://discuss.appium.io/t/help-needed-expectedconditions-invisibilityof

0reactions
OnurSerbescommented, Oct 14, 2022

In some pages it exists I can take the text but some of them don’t have it, that is the reason why I am using isDisplayed() am I using wrong ? As I stated, I also tried to avoid it without using isDisplayed() (with isElementPresent function but it’s not working either) because of the prevent error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - try catch is not working on isDisplayed() in selenium and ...
The trick here is to use findElementS (notice the S). This gives a list of found elements, if 0 than there is no...
Read more >
How To Use isDisplayed() In Selenium WebDriver | LambdaTest
This article explains how to use isDisplayed() in Selenium WebDriver while performing Selenium automation testing.
Read more >
Check Visibility of Web Elements Using Various Types ...
The method deals with the visibility of all kinds of web elements not just limiting to any one type. isEnabled(). isEnabled() is the...
Read more >
Handling Errors by Using Try Functions - Dynamics NAV
Describes how to use Try functions in C/AL, which enable you to handle errors that occur in the application during code execution.
Read more >
Error Handling — The Swift Programming Language (Swift 5.7)
There are a number of ways this task can fail, including the file not ... by correcting the problem, trying an alternative approach,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found