getAttribute("class") returns a NoSuchElementException


Hi, I am testing an Android app with Appium I’d like to output few attributes. But it is weird that I can get “checked” but not for “class”.

    WebElement element = _wd.findElementById("XXXXXX");
    System.out.println("checked="+element.getAttribute("checked"));  // print out "checked=true"
    System.out.println("class="+element.getAttribute("class"));          // NoSuchElementException

Here is the output, I got NoSuchElement exception.


org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15 milliseconds
For documentation on this error, please visit:
Build info: version: ‘2.43.1’, revision: ‘5163bceef1bc36d43f3dc0b83c88998168a363a0’, time: ‘2014-09-10 09:43:55’
System info: host: ‘SEANS-W540-W8’, ip: ‘’, ‘Windows 8.1’, os.arch: ‘amd64’, os.version: ‘6.3’, java.version: ‘1.7.0_60’
Session ID: 3da5e447-fe32-45c7-908c-484c33ebf11b
Driver info:

Is there anybody can explain it?

Any help is appreciated.



any solutions to this?


More than likely the error is accurate and it simply couldn’t locate the element using the data you’ve provided.

  • Your locator is incorrect
  • You’re testing Android and the element is out of the viewable area

Someone can help you craft a correct locator if you paste the page source XML for your AUT.


getAttribute (“className”) will work.
Even I faced the same issue.