nightwatch: isVisible is calling getElementProperty on Safari, which is not supported for iOS
Describe the bug
We’re trialling cross-browser testing user Browserstack, which enables us to test against mobile browsers. There was a change made to isVisible in the API in October that’s supposed to temporarily fix some issue in Safari (see here), but this is causing tests with Browserstack using an iOS to fail. With the error Error while running .getElementProperty() protocol action: Appium error: Method has not yet been implemented. Interestingly, MacOS Safari via Browserstack also fails with, though not with the same error (see debug-macos.log below).
Is this condition still necessary, and if so, what for? Is there a way we can work around it for browserstack, as both browsers work if the condition is removed.
Sample test
sampleTest.js
module.exports = {
"Visible iOS test": function (browser) {
browser
.url("https://example.com/")
browser.assert.visible('body div h1')
}
}
Run with command
For iOS Safari
$ nightwatch test/sampleTest.js -e safari
For MacOS Safari
$ nightwatch test/sampleTest.js -e iphone
Verbose output
debug-iphone.log
Using insecure HTTP connection on port 80. Consider using SSL by setting port to 443 in your Nightwatch configution.
[Visible Test] Test Suite
=========================
ℹ Connected to hub-cloud.browserstack.com on port 80 (10454ms).
Using: safari (undefined) on MAC 12.1 platform.
Running: Visible iOS test
Error while running .getElementProperty() protocol action: Appium error: Method has not yet been implemented
Error while running .getElementProperty() protocol action: Appium error: Method has not yet been implemented
Error while running .getElementProperty() protocol action: Appium error: Method has not yet been implemented
Error while running .getElementProperty() protocol action: Appium error: Method has not yet been implemented
Error while running .getElementProperty() protocol action: Appium error: Method has not yet been implemented
✖ Testing if element <body div h1> is visible in 5000ms - expected "is visible" but got: "element could not be located" (5710ms)
at Object.Visible iOS test (/Users/harleyf/IdeaProjects/nightwatch-demo/tests/visibleTest.js:6:24)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
FAILED: 1 assertions failed and 5 errors (7.713s)
See more info, video, & screenshots on Browserstack:
[Browserstack URL]
_________________________________________________
TEST FAILURE: 5 errors during execution; 1 assertions failed, 0 passed (19.896s)
✖ visibleTest
– Visible iOS test (7.713s)
Testing if element <body div h1> is visible in 5000ms - expected "is visible" but got: "element could not be located" (5710ms)
at Object.Visible iOS test (/Users/harleyf/IdeaProjects/nightwatch-demo/tests/visibleTest.js:6:24)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
TimeoutError: An error occurred while running .isVisible() command on <body div h1>:
{"value":false}
at processTicksAndRejections (internal/process/task_queues.js:85:5)
TimeoutError: An error occurred while running .isVisible() command on <body div h1>:
{"value":false}
at processTicksAndRejections (internal/process/task_queues.js:85:5)
TimeoutError: An error occurred while running .isVisible() command on <body div h1>:
{"value":false}
at processTicksAndRejections (internal/process/task_queues.js:85:5)
TimeoutError: An error occurred while running .isVisible() command on <body div h1>:
{"value":false}
at processTicksAndRejections (internal/process/task_queues.js:85:5)
TimeoutError: An error occurred while running .isVisible() command on <body div h1>:
{"value":false}
at processTicksAndRejections (internal/process/task_queues.js:85:5)
debug-macos.log
Using insecure HTTP connection on port 80. Consider using SSL by setting port to 443 in your Nightwatch configution.
[Visible Test] Test Suite
=========================
ℹ Connected to hub-cloud.browserstack.com on port 80 (10628ms).
Using: Safari (12.1.2) on macOS platform.
Running: Visible iOS test
✖ Testing if element <body div h1> is visible in 5000ms - expected "is visible" but got: "element could not be located" (5850ms)
at Object.Visible iOS test (/Users/harleyf/IdeaProjects/nightwatch-demo/tests/visibleTest.js:6:24)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
FAILED: 1 assertions failed and 4 errors (8.358s)
See more info, video, & screenshots on Browserstack:
https://automate.browserstack.com/builds/e2980acd9f7cc70b18943add625cedb7fad86965/sessions/9de9b04bf3be91090ce2b2dcf13a1772a5360156
_________________________________________________
TEST FAILURE: 4 errors during execution; 1 assertions failed, 0 passed (20.656s)
✖ visibleTest
– Visible iOS test (8.358s)
Testing if element <body div h1> is visible in 5000ms - expected "is visible" but got: "element could not be located" (5850ms)
at Object.Visible iOS test (/Users/harleyf/IdeaProjects/nightwatch-demo/tests/visibleTest.js:6:24)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
TimeoutError: An error occurred while running .isVisible() command on <body div h1>: undefined; undefined
{"value":true}
at processTicksAndRejections (internal/process/task_queues.js:85:5)
TimeoutError: An error occurred while running .isVisible() command on <body div h1>: undefined; undefined
{"value":true}
at processTicksAndRejections (internal/process/task_queues.js:85:5)
TimeoutError: An error occurred while running .isVisible() command on <body div h1>: undefined; undefined
{"value":true}
at processTicksAndRejections (internal/process/task_queues.js:85:5)
TimeoutError: An error occurred while running .isVisible() command on <body div h1>: undefined; undefined
{"value":true}
at processTicksAndRejections (internal/process/task_queues.js:85:5)
Configuration
nightwatch.json
{
"src_folders": ["tests"],
"selenium": {
"start_process": false,
"host": "hub-cloud.browserstack.com",
"username": "username",
"access_key": "access_key",
"port": 80
},
"test_settings": {
"iphone": {
"desiredCapabilities": {
"browserstack.user": "username",
"browserstack.key": "access_key",
"browserstack.local": "true",
"device": "iPhone XS",
"realMobile": "true",
"os_version": "12"
}
},
"safari": {
"desiredCapabilities": {
"browserstack.user": "username",
"browserstack.key": "access_key",
"browserstack.local": "true",
"os": "OS X",
"os_version": "Mojave",
"browser": "Safari",
"browser_version": "12.0",
"resolution": "1920x1080"
}
}
}
}
Your Environment
| Executable | Version |
|---|---|
nightwatch --version |
1.3.2 |
npm --version |
6.9.0 |
yarn --version |
1.3.2 |
node --version |
12.6.0 |
| Browser driver | Version |
|---|---|
| Browserstack | n/a (see config) |
| OS | Version |
|---|---|
| iOS | 12 |
| macOS Mojave | unknown |
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 11
- Comments: 29 (16 by maintainers)
@WilliamABradley would you mind raising a separate issue for the waitForElementVisible failure?I’ve got an idea how to fix it, but the pathway seems to be a little different. However, the workaround @tellisnz-shift posted might work for you in the meantime.Actually, never mind about the new issue, I’m working on a solution as I think it’s a shared problem between isVisible, getValue, and the underlying _waitForDisplayed commands.
@robert-cui-tile I’ve not had a chance to investigate this further yet, Browserstack still seems to think there isn’t a problem. I’ll try and continue looking into it next week. In the meantime, if you’re comfortable patching your copy of Nightwatch you can take the changes in my PR and apply them directly.
My PR for this issue is still open, but needs some more investigation into the behaviour with Browserstack and SauceLabs (I can replicate on both). I’ve had conversation with Browserstack’s support and they claim it’s working on their end, but I haven’t yet been able to follow up. Anyone else with capacity to investigate further are more than welcome to take my PR and carry on where I left off
@Topperfalkon in the latest version, safaridriver doesn’t include the
/displayedendpoint, so if you try to runassert.visible()it fails. The best way to address this I guess it would be to check if Safari is local, usingthis.settings.webdriver.start_processin the same place where we check for browser name.I patched the Nightwatch api locally to skip the conditional, but we’re not currently using this for our CI tests, so that was fine enough to prove the issue.
The offending conditional is here: https://github.com/nightwatchjs/nightwatch/blob/master/lib/api/element-commands/isVisible.js#L53
If you need this for CI, I’d suggest taking a fork and removing the conditional for your usage.
I haven’t tested it against macOS Safari on an actual device yet, it might be there’s something specific with running it via Browserstack. I’ve not been able to do a more detailed investigation yet.
I would have offered a pull request to remove the conditional, but it was added recently so was hoping to understand from the Nightwatch team why it was added.