Method MobileElement.getAttribute() throws NoSuchElementException
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.3k
- Forks
- 752
- Avg merge
- 6d 21h
- Merged PRs (30d)
- 8
Description
Description
Call to element.getAttribute("MISSING_ATTR") throws NoSuchElementException in Appium, but returns null in Chrome, Firefox and others webdrivers. I believe Appium should also return null instead of throwing exception. It's a totally valid case when I want to log some attributes of the element. I don't want to write multiple try/catch blocks to do it.
Environment
- io.appium:java-client:7.1.0
- Appium server version: 1.7.2
Code To Reproduce Issue
assertNull(appiumDriver.findElement(By.id("result")).getAttribute("FOOBAR"));
Causes the exception:
https://gist.github.com/asolntsev/36ad1bdfce253cb5ba8210d1c2f909e0
Link to Appium logs
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getAttribute","params":{"attribute":"class","elementId":"5"}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"This element does not have the 'class' attribute"}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Java client's MobileElement.getAttribute() path and compare its handling with the WebDriver behavior described in the issue. Reproduce the call using the provided assertNull example and add or update a regression test so a missing attribute returns null rather than NoSuchElementException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 40/100