admc / wd

A node.js client for webdriver/selenium 2.
Other
1.53k stars 402 forks source link

Unexpected data in simpleCallback #514

Open funkyvisions opened 6 years ago

funkyvisions commented 6 years ago

I'm getting an error down in the bowels of wd. This only happens maybe 1 out of 30 tests that I run.

Here's the test that is failing

function setApplicationBrowser(context) {

    applicationContext = context;
    capabilities = applicationContext.capabilities;

    browser = applicationContext.driver.contexts()
        .then(function(contexts) {
            let contextId;
            for (let index in contexts) {
                // Find the Android (WEBVIEW_org.oclc.digby) or iOS (WEBVIEW_*.1) WEBVIEW
                if (contexts.hasOwnProperty(index) && ((contexts[index].startsWith("WEBVIEW_")
                        && contexts[index].endsWith(".1")) || contexts[index] === "WEBVIEW_org.oclc.digby")) {
                    contextId = index;
                    break;
                }
            }
            return applicationContext.driver.context(contexts[contextId]);
        })
        .setImplicitWaitTimeout(30000);

    return browser;
}

    Given(/^I loaded the app in mock mode$/, function() {
        return utilities.setApplicationBrowser(this)
//            .sleep(1000)
            .execute('window.localStorage.setItem("USE_MOCK_AUTH", true);' +
                'window.localStorage.setItem("USE_MOCK_DATA", true);' +
                'window.location.href = "index.html";')
//            .sleep(2000);
    });

and the error

Error: [context()] Unexpected data in simpleCallback.
         at exports.newError (/Users/daviesd/workspace/wms-circ-app/node_modules/wd/lib/utils.js:145:13)
         at /Users/daviesd/workspace/wms-circ-app/node_modules/wd/lib/callbacks.js:42:12
         at /Users/daviesd/workspace/wms-circ-app/node_modules/wd/lib/webdriver.js:179:5
         at Request._callback (/Users/daviesd/workspace/wms-circ-app/node_modules/wd/lib/http-utils.js:88:7)
         at Request.self.callback (/Users/daviesd/workspace/wms-circ-app/node_modules/wd/node_modules/request/request.js:186:22)
         at emitTwo (events.js:125:13)
         at Request.emit (events.js:213:7)
         at Request.<anonymous> (/Users/daviesd/workspace/wms-circ-app/node_modules/wd/node_modules/request/request.js:1081:10)
         at emitOne (events.js:115:13)
         at Request.emit (events.js:210:7)
         at IncomingMessage.<anonymous> (/Users/daviesd/workspace/wms-circ-app/node_modules/wd/node_modules/request/request.js:1001:12)
         at Object.onceWrapper (events.js:314:30)
         at emitNone (events.js:110:20)
         at IncomingMessage.emit (events.js:207:7)
         at endReadableNT (_stream_readable.js:1059:12)
         at _combinedTickCallback (internal/process/next_tick.js:138:11)

This seems similar to what was discuss in https://github.com/admc/wd/issues/478.

I put some logging in callback.js and "data" is equal to this Parameters were incorrect. We wanted {"required":["name"]} and you sent []

Not sure where to keep digging. Can you provide any guidance? It fails just as the test is starting up and it's not necessarily the same test that fails each time. It's random and infrequent, but still an annoyance.

Using appium 1.7.1 and wd 1.4.1. iOS Simulator 11.2.

Some searching shows that error spit out here https://github.com/appium/appium/issues/6135, but probably totally unrelated.

senaev commented 6 years ago

i have the same exact problem