Last active
April 18, 2017 22:00
-
-
Save jedwards1211/646b825f3283babfffa2ddc340f860d2 to your computer and use it in GitHub Desktop.
webdriver parallel executeAsync bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {expect} from 'chai' | |
import * as webdriverio from 'webdriverio' | |
import {run as runPhantomjs} from 'phantomjs-prebuilt' | |
describe('executeAsync', function () { | |
this.timeout(10000) | |
let phantomjs | |
let browser | |
before(async function () { | |
phantomjs = await runPhantomjs('--webdriver=4444') | |
browser = webdriverio.remote({ | |
desiredCapabilities: {browserName: 'phantomjs'}, | |
logLevel: 'verbose' | |
}) | |
await browser.init() | |
}) | |
after(async function () { | |
if (browser) await browser.end() | |
if (phantomjs) phantomjs.kill() | |
}) | |
it("parallel calls don't interfere with each other", () => Promise.all([ | |
browser.executeAsync( | |
(count, callback) => setTimeout(() => callback(count), 2000), | |
1 | |
).then(({value: count}) => expect(count).to.equal(1)), | |
browser.executeAsync( | |
(count, callback) => setTimeout(() => callback(count), 2000), | |
2 | |
).then(({value: count}) => expect(count).to.equal(2)), | |
])) | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
executeAsync | |
======================================================================================= | |
Selenium 2.0 / webdriver protocol bindings implementation with helper commands in nodejs. | |
For a complete list of commands, visit http://webdriver.io/api.html. | |
======================================================================================= | |
[16:52:17] COMMAND POST "/wd/hub/session" | |
[16:52:17] DATA {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"browserName":"phantomjs","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.6.2","name":"webdriverio"}}} | |
[16:52:17] INFO SET SESSION ID 4a3e0890-2481-11e7-94ca-3f5238c619af | |
[16:52:17] RESULT {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"mac-unknown-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}} | |
[16:52:17] COMMAND POST "/wd/hub/session/4a3e0890-2481-11e7-94ca-3f5238c619af/execute_async" | |
[16:52:17] DATA {"script":"return (function (count, callback) {\n return setTimeout(function () {\n return callback(count);\n }, 2000);\n }).apply(null, arguments)","args":[1]} | |
[16:52:17] COMMAND POST "/wd/hub/session/4a3e0890-2481-11e7-94ca-3f5238c619af/execute_async" | |
[16:52:17] DATA {"script":"return (function (count, callback) {\n return setTimeout(function () {\n return callback(count);\n }, 2000);\n }).apply(null, arguments)","args":[2]} | |
[16:52:19] RESULT 1 | |
1) can be run in parallel without issues | |
[16:52:19] RESULT 1 | |
[16:52:19] COMMAND DELETE "/wd/hub/session/4a3e0890-2481-11e7-94ca-3f5238c619af" | |
[16:52:19] DATA {} | |
[16:52:19] RESULT {} | |
0 passing (3s) | |
1 failing | |
1) executeAsync can be run in parallel without issues: | |
AssertionError: expected 1 to equal 2 | |
+ expected - actual | |
-1 | |
+2 | |
at Object.<anonymous> (test/executeAsync.js:32:49) | |
at Object.exec (node_modules/webdriverio/build/lib/helpers/safeExecute.js:28:24) | |
at Object.resolve (node_modules/webdriverio/build/lib/webdriverio.js:193:29) | |
at node_modules/webdriverio/build/lib/webdriverio.js:503:32 | |
at _fulfilled (node_modules/q/q.js:834:54) | |
at self.promiseDispatch.done (node_modules/q/q.js:863:30) | |
at Promise.promise.promiseDispatch (node_modules/q/q.js:796:13) | |
at node_modules/q/q.js:604:44 | |
at runSingle (node_modules/q/q.js:137:13) | |
at flush (node_modules/q/q.js:125:13) | |
at _combinedTickCallback (internal/process/next_tick.js:67:7) | |
at process._tickDomainCallback (internal/process/next_tick.js:122:9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment