-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
screen off before wake up to clean text field, avoid no element crash #498
screen off before wake up to clean text field, avoid no element crash #498
Conversation
const el = await driver.findElOrEls('xpath', "//*[contains(@resource-id, 'id/key_enter')]", false); | ||
await driver.click(util.unwrapElement(el)); | ||
// Waits a bit for the device to be unlocked | ||
// Some devices accept the entered key automatically | ||
await sleep(UNLOCK_WAIT_TIME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I rushed commands without this wait before pressKeyCode, rarely UI2 sever crashed.
Thus, I leave this and call isScreenLocked
after this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this note as the comment in the code
lib/unlock-helpers.js
Outdated
@@ -9,6 +9,8 @@ const PATTERN_UNLOCK = 'pattern'; | |||
const FINGERPRINT_UNLOCK = 'fingerprint'; | |||
const UNLOCK_TYPES = [PIN_UNLOCK, PASSWORD_UNLOCK, PATTERN_UNLOCK, FINGERPRINT_UNLOCK]; | |||
const KEYCODE_NUMPAD_ENTER = '66'; | |||
const KEYCODE_POWER = '26'; | |||
const KEYCODE_WAKEUP = '224'; // Can work over API Level 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key codes may be integers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either worked fine. I defined as string because of the previous implementation.
I ensured this worked, including KEYCODE_NUMPAD_ENTER
, worked as int as well.
lib/unlock-helpers.js
Outdated
const el = await driver.findElOrEls('xpath', "//*[contains(@resource-id, 'id/key_enter')]", false); | ||
await driver.click(util.unwrapElement(el)); | ||
// Waits a bit for the device to be unlocked | ||
// Some devices accept the entered key without enter key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...accept entering the code without pressing the Enter key
When I tried to pin unlock:
To avoid the error, I did:
KEYCODE_POWER
before wake upKEYCODE_NUMPAD_ENTER
when we tap enter keyid/key_enter
KEYCODE_NUMPAD_ENTER
after checking screen lockI tested:
They worked well than before. I'm not sure this can cover all of android devices though...
(I have no mush Chinese devices, for example..)