nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.83k stars 1.32k forks source link

`waitForElementVisible` is broken in Safari using NW v.1.3.1 jsonwire #2258

Closed ruben0626 closed 4 years ago

ruben0626 commented 4 years ago

Describe the bug

Seems like if we return this:

https://github.com/nightwatchjs/nightwatch/blob/48c542e861b1cb40a46b1cf9607f351b74de6d11/lib/api/element-commands/_waitForDisplayed.js#L10

Then it won't work with the isResultSuccess in the jsonwire https://github.com/nightwatchjs/nightwatch/blob/1e50c8d9aab2aea48fd0301d2f65367adbe7e0ad/lib/transport/jsonwire.js#L55

I guess we should also return

{
   value: result.value === false,
   status: result.value === false ? SUCCESS : ELEMENT_NOT_VISIBLE 
}

Sample test

sampleTest.js

```js // Please add the sample test here module.exports = { 'Click callback should not be ignored': (client) => { client .url('http://example.com') .waitForElementVisible('body', 5000); client.isVisible('body', (result) => { console.log(result); }); }, } ```

Run with command

$ nightwatch test/sampleTest.js --your-other-arguments-here

Verbose output

debug.log

```txt Starting Selenium Server on port 4444... Selenium Server up and running on port 4444 with pid: 1568 (970ms). [Example Funcspec] Test Suite ============================= ⠋ Connecting to 127.0.0.1 on port 4444... Request POST /wd/hub/session { desiredCapabilities: { browserName: 'safari', platform: 'ANY', safariOptions: { args: [ '--start-maximized', '--start-fullscreen', 'auto-open-devtools-for-tabs' ], mobileEmulation: { deviceMetrics: [Object] } }, ⠸ Connecting to 127.0.0.1 on port 4444... Response 200 POST /wd/hub/session (2774ms) { status: 0, sessionId: '16F22B12-807A-4F49-8157-86E511BA9681', value: { 'safari:platformVersion': '10.14.6', 'safari:automaticInspection': false, 'webkit:WebRTC': { DisableICECandidateFiltering: false, DisableInsecureMediaCapture: false }, browserVersion: '13.0.3', strictFileInteractability: false, browserName: 'Safari', 'safari:useSimulator': false, 'safari:automaticProfiling': false, 'safari:platformBuildVersion': '18G1012', acceptInsecureCerts: false, setWindowRect: true, platformName: 'macOS', 'safari:diagnose': false, ℹ Connected to 127.0.0.1 on port 4444 (2817ms). Using: Safari (13.0.3) on macOS platform. Received session with ID: 16F22B12-807A-4F49-8157-86E511BA9681 → Running [before]: → Completed [before]. Running: Click callback should not be ignored → Running [beforeEach]: → Completed [beforeEach]. → Running command: url ('http://example.com') Request POST /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/url { url: 'http://example.com' } Response 200 POST /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/url (388ms) { state: 'success', sessionId: null, value: null, status: 0 } → Completed command: url ('http://example.com') (392ms) → Running command: waitForElementVisible ('body', 5000) Request POST /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/elements { using: 'css selector', value: 'body' } Response 200 POST /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/elements (52ms) { state: 'success', sessionId: null, value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667' } ], status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (24ms) { state: 'success', sessionId: null, value: false, status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (9ms) { state: 'success', sessionId: null, value: false, status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (8ms) { state: 'success', sessionId: null, value: false, status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (9ms) { state: 'success', sessionId: null, value: false, status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (8ms) { state: 'success', sessionId: null, value: false, status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (9ms) { state: 'success', sessionId: null, value: false, status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (9ms) { state: 'success', sessionId: null, value: false, status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (17ms) { state: 'success', sessionId: null, value: false, status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (8ms) { state: 'success', sessionId: null, value: false, status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (14ms) { state: 'success', sessionId: null, value: false, status: 0 } Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/element/node-A9330F28-AAE0-41F4-A6B3-5A9453E5F667/property/hidden (14ms) { state: 'success', sessionId: null, value: false, status: 0 } → Completed command: waitForElementVisible ('body', 5000) (5225ms) → Running [afterEach]: → Completed [afterEach]. FAILED: 1 errors (5.633s) TimeoutError: timeout error at process._tickCallback (internal/process/next_tick.js:68:7) → Running [after]: → Completed [after]. → Running command: end ([Function]) Failures in "Click callback should not be ignored". Taking screenshot... → Running command: saveScreenshot ('/Users/rjimenez/Development/walmart/walmart-test-framework/packages/demo/reports/example.funcspec/Click-callback-should-not-be-ignored_FAILED_Nov-28-2019-160723-GMT-0400-(Atlantic-Standard.png', [Function]) → Running command: screenshot (false, [Function]) Request GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/screenshot Response 200 GET /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681/screenshot (104ms) { state: 'success', sessionId: null, value: '', status: 0, suppressBase64Data: true } → Completed command: screenshot (false, [Function]) (125ms) → Completed command: saveScreenshot ('/Users/rjimenez/Development/walmart/walmart-test-framework/packages/demo/reports/example.funcspec/Click-callback-should-not-be-ignored_FAILED_Nov-28-2019-160723-GMT-0400-(Atlantic-Standard.png', [Function]) (129ms) → Running command: session ('delete', [Function]) Request DELETE /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681 Response 200 DELETE /wd/hub/session/16F22B12-807A-4F49-8157-86E511BA9681 (16ms) { state: 'success', sessionId: null, value: null, status: 0 } → Completed command: end ([Function]) (152ms) → Completed command: session ('delete', [Function]) (20ms) [Pages/Test] Test Suite ======================= ⠋ Connecting to 127.0.0.1 on port 4444... Request POST /wd/hub/session { desiredCapabilities: { browserName: 'safari', platform: 'ANY', safariOptions: { args: [ '--start-maximized', '--start-fullscreen', 'auto-open-devtools-for-tabs' ], mobileEmulation: { deviceMetrics: [Object] } }, ⠹ Connecting to 127.0.0.1 on port 4444... Response 200 POST /wd/hub/session (1811ms) { status: 0, sessionId: 'EE48DCF2-8CB5-497B-A2E9-16B02A699636', value: { 'safari:platformVersion': '10.14.6', 'safari:automaticInspection': false, 'webkit:WebRTC': { DisableICECandidateFiltering: false, DisableInsecureMediaCapture: false }, browserVersion: '13.0.3', strictFileInteractability: false, browserName: 'Safari', 'safari:useSimulator': false, 'safari:automaticProfiling': false, 'safari:platformBuildVersion': '18G1012', acceptInsecureCerts: false, setWindowRect: true, platformName: 'macOS', 'safari:diagnose': false, ℹ Connected to 127.0.0.1 on port 4444 (1814ms). Using: Safari (13.0.3) on macOS platform. Received session with ID: EE48DCF2-8CB5-497B-A2E9-16B02A699636 → Running [before]: → Completed [before]. → Running [after]: → Completed [after]. → Running command: end ([Function]) → Running command: session ('delete', [Function]) Request DELETE /wd/hub/session/EE48DCF2-8CB5-497B-A2E9-16B02A699636 Response 200 DELETE /wd/hub/session/EE48DCF2-8CB5-497B-A2E9-16B02A699636 (9ms) { state: 'success', sessionId: null, value: null, status: 0 } → Completed command: end ([Function]) (15ms) → Completed command: session ('delete', [Function]) (13ms) _________________________________________________ TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (11.558s) ✖ example.funcspec ```

Configuration

nightwatch.json

```js { "src_folders": [ "./src" ], "output_folder": "reports", "test_settings": { "default": { "selenium": { "start_process": true, "server_path": "../../node_modules/selenium-server/lib/runner/selenium-server-standalone-3.141.59.jar", "log_path": "reports", "host": "127.0.0.1", "port": 4444 }, "screenshots": { "path": "./reports", "enabled": true, "on_failure": true, "on_error": true }, "desiredCapabilities": { "browserName": "safari", "safariOptions": { "args": [ "--start-maximized", "--start-fullscreen", "auto-open-devtools-for-tabs" ], "mobileEmulation": { "deviceMetrics": { "width": 1280, "height": 800 } } } } } } } ```

Your Environment

Executable Version
nightwatch --version 1.3.0
npm --version 6.12.1
yarn --version 1.17.3
node --version 10.16.3

| Browser driver | Version | | Safari | 13.0.3 |

| OS | Version | | macOS Mojava | 10.14.6 |

beatfactor commented 4 years ago

Can you please use the new issue template when filing a new bug? Feel free to re-open and update or a file a new one. Thanks!

ruben0626 commented 4 years ago

@beatfactor Sorry about that, I created a new one: https://github.com/nightwatchjs/nightwatch/issues/2259