Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to obtain password attribute #6281

Closed
mbknieri opened this issue Mar 14, 2016 · 11 comments
Closed

Unable to obtain password attribute #6281

mbknieri opened this issue Mar 14, 2016 · 11 comments
Labels
Android related to Android-native driver(s) Bug a problem that needs fixing P1

Comments

@mbknieri
Copy link

mbknieri commented Mar 14, 2016

The problem

When I attempt to obtain the password attribute, Appium responds with an error that the element can not be located.

When viewing the element using the Appium inspector, it is clear that the element does have the password attribute:

screen shot 2016-03-14 at 2 55 53 pm

## Environment

Appium version: v1.4.13, v1.4.16
Desktop OS: Yosemite v10.10.5
Node.js Version: v4.2.3
Mobile Platform: Android
Emulator: Genymotion, Samsung Galaxy S6 - 6.0.0 - API 23
Noticed error on both Appium CLI and Appium.app

Link to Appium logs

Can not post full log on gist. Here is the log output from where the error occurred:

info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.view.View[2]/android.widget.EditText[1]","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.view.View[2]/android.widget.EditText[1]","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.view.View[2]/android.widget.EditText[1] using XPATH with the contextId:  multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText, INSTANCE=1]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"18"}}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"18"},"sessionId":"6aeafb9b-f259-495a-8e58-c03eec0cf737"}
info: <-- POST /wd/hub/session/6aeafb9b-f259-495a-8e58-c03eec0cf737/element 200 1471.686 ms - 88 {"status":0,"value":{"ELEMENT":"18"},"sessionId":"6aeafb9b-f259-495a-8e58-c03eec0cf737"}
info: --> GET /wd/hub/session/6aeafb9b-f259-495a-8e58-c03eec0cf737/element/18/attribute/password {}
info: [debug] Pushing command to appium work queue: ["element:getAttribute",{"elementId":"18","attribute":"password"}]
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"This element does not have the 'password' attribute"},"sessionId":"6aeafb9b-f259-495a-8e58-c03eec0cf737"}
info: <-- GET /wd/hub/session/6aeafb9b-f259-495a-8e58-c03eec0cf737/element/18/attribute/password 500 2.976 ms - 230 
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getAttribute","params":{"elementId":"18","attribute":"password"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getAttribute
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":7,"value":"This element does not have the 'password' attribute"}
info: --> DELETE /wd/hub/session/6aeafb9b-f259-495a-8e58-c03eec0cf737 {}
info: Shutting down appium session

Code To Reproduce Issue [ Good To Have ]

used java-client's .getAttribute("password") on a WebElement.

@triager triager added the Needs Triage bugs which are not yet confirmed label Mar 14, 2016
@imurchie
Copy link
Contributor

There is currently no way to pull this information. I'm not sure where the .app is getting this from.

If it is a WebElement you might be able to change contexts and get the information.

@mbknieri
Copy link
Author

I looked at the implementation for Appium.app. It looks like the attribute is obtained from the last page source's xml response. I hit the Refresh button in the Appium inspector and saw that the server response did provide the password attribute:

android.widget.EditText index="1" text="" class="android.widget.EditText" package="" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="true" selected="false" bounds="[52,788][1388,944]" resource-id="" instance="1"/

If I understand your response correctly, there is currently not a way to obtain this attribute from the server even though it is provided in the xml response after getting the page source? I am able to get other attributes for the element (ex. getAttribute("resourceId") works).

@imurchie
Copy link
Contributor

Ah. Ok, it is just parsing the XML, then. The getAttribute method queries the device for the information, and the device does allow us to check for password. It seems like you'll have to get the source and find your element in there.

The attributes that can be retrieved directly can be found here:

booleans: https://github.com/appium/appium-android-bootstrap/blob/master/bootstrap/src/io/appium/android/bootstrap/AndroidElement.java#L94-L121

strings: https://github.com/appium/appium-android-bootstrap/blob/master/bootstrap/src/io/appium/android/bootstrap/AndroidElement.java#L182-L202

@gluxhappy
Copy link
Contributor

Does this issue solved?
I have the same issue now, and i am trying to find a solution.

@darya1844
Copy link

I have the same problem and would be glad to get any solution.

@Yelisey
Copy link

Yelisey commented Sep 30, 2016

Please, fix this bug/issue-bug..

@dpgraham dpgraham added Bug a problem that needs fixing and removed Needs Triage bugs which are not yet confirmed labels Nov 22, 2016
@imurchie imurchie added Android related to Android-native driver(s) P1 labels Jul 19, 2017
@Carlgege
Copy link

@sravanmedarapu @mykola-mokhnach @imurchie
I have solved this issue after update the UiObject2Element from the source code of uiautomator2 server
(appium\node_modules\appium-uiautomator2-driver\node_modules\appium-uiautomator2-server\app\src).

public boolean getBoolAttribute(final String attr) throws UiObjectNotFoundException, NoAttributeFoundException, UiAutomator2Exception {
        boolean res;
        if ("enabled".equals(attr)) {
            res = element.isEnabled();
        } else if ("checkable".equals(attr)) {
            res = element.isCheckable();
        } else if ("checked".equals(attr)) {
            res = element.isChecked();
        } else if ("clickable".equals(attr)) {
            res = element.isClickable();
        } else if ("focusable".equals(attr)) {
            res = element.isFocusable();
        } else if ("focused".equals(attr)) {
            res = element.isFocused();
        } else if ("longClickable".equals(attr)) {
            res = element.isLongClickable();
        } else if ("scrollable".equals(attr)) {
            res = element.isScrollable();
        } else if ("selected".equals(attr)) {
            res = element.isSelected();
        } else if ("displayed".equals(attr)) {
            res = invoke(method(UiObject2.class, "getAccessibilityNodeInfo"), element) != null ? true : false;
        } else if ("password".equals(attr)) {
            res = AccessibilityNodeInfoGetter.fromUiObject(element).isPassword();
        }  else {
            throw new NoAttributeFoundException(attr);
        }
        return res;
    } 

@mykola-mokhnach
Copy link
Collaborator

You are welcome to create a PR containing your fix ;)

Here you can find server source: https://github.com/appium/appium-uiautomator2-server

@jlipps
Copy link
Member

jlipps commented Aug 30, 2017

@Carlgege yes, please do submit a PR!

sravanmedarapu added a commit to appium/appium-uiautomator2-server that referenced this issue Aug 31, 2017
@mykola-mokhnach
Copy link
Collaborator

Closed as fixed

@lock
Copy link

lock bot commented Apr 30, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Apr 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android related to Android-native driver(s) Bug a problem that needs fixing P1
Projects
None yet
Development

No branches or pull requests

10 participants