I was trying to put an implicit wait in selenium java script with mocha but i see the following error:
ReferenceError: timeUnit is not defined
Below is the code snippet i used:
driver.manage().timeouts().implicitlyWait(20, timeUnit.SECONDS);
and the stack trace I see is:
at Context.<anonymous> (C:\node_modules\Script\login_scenario.js:32:50)
at C:\node_modules\Script\node_modules\selenium-webdriver\testing\index.js:142:19
at new promise.Promise (C:\node_modules\Script\node_modules\selenium-webdriver\lib\webdriver\promise.js:355:5)
at controlFlowExecute (C:\node_modules\Script\node_modules\selenium-webdriver\testing\index.js:127:14)
at promise.ControlFlow.runInFrame_ (C:\node_modules\Script\node_modules\selenium-webdriver\lib\webdriver\promise.js:1877:20)
at promise.ControlFlow.runEventLoop_ (C:\node_modules\Script\node_modules\selenium-webdriver\lib\webdriver\promise.js:1755:8
at null.<anonymous> (C:\node_modules\Script\node_modules\selenium-webdriver\lib\webdriver\promise.js:2056:12)
at goog.async.run.processWorkQueue (C:\node_modules\Script\node_modules\selenium-webdriver\lib\goog\async\run.js:125:21)
: Task: Automation of Shop Management Login scenario
at Context.ret (C:\node_modules\Script\node_modules\selenium-webdriver\testing\index.js:126:10)
at Test.Runnable.run (C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runnable.js:233:15)
at Runner.runTest (C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:387:10)
at C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:470:12
at next (C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:312:14)
at C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:322:7
at next (C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:257:23)
at Immediate._onImmediate (C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:289:5)
at processImmediate [as _immediateCallback] (timers.js:358:17)
implicitlyWait() in javascript selenium bindings accepts a single argument - a timeout in milliseconds:
driver.manage().timeouts().implicitlyWait(20000);
You are probably mixing it up with implicitlyWait() method from java selenium bindings, which allows you to specify the timeout unit alongside with the timeout itself.
Related
Getting below issue while integrating kafka with node after certain time of application get started in node server.
There is not any log in kafka server as well as it is up and running.
/app/node_modules/async/dist/async.js:5329
return callback.apply(null, arguments);
^
NestedError: refreshBrokerMetadata failed
at /app/node_modules/kafka-node/lib/kafkaClient.js:378:35
at /app/node_modules/async/dist/async.js:473:16
at next (/app/node_modules/async/dist/async.js:5329:29)
at /app/node_modules/async/dist/async.js:969:16
at KafkaClient.getAvailableBroker (/app/node_modules/kafka-node/lib/kafkaClient.js:330:12)
at /app/node_modules/kafka-node/lib/kafkaClient.js:373:23
at nextTask (/app/node_modules/async/dist/async.js:5324:14)
at Object.waterfall (/app/node_modules/async/dist/async.js:5334:5)
at KafkaClient.refreshBrokerMetadata (/app/node_modules/kafka-node/lib/kafkaClient.js:372:9)
at Immediate._onImmediate (/app/node_modules/kafka-node/lib/kafkaClient.js:782:20)
Caused By: Error: Unable to find available brokers to try
at KafkaClient.getAvailableBroker (/app/node_modules/kafka-node/lib/kafkaClient.js:330:21)
at /app/node_modules/kafka-node/lib/kafkaClient.js:373:23
at nextTask (/app/node_modules/async/dist/async.js:5324:14)
at Object.waterfall (/app/node_modules/async/dist/async.js:5334:5)
at KafkaClient.refreshBrokerMetadata (/app/node_modules/kafka-node/lib/kafkaClient.js:372:9)
at Immediate._onImmediate (/app/node_modules/kafka-node/lib/kafkaClient.js:782:20)
at processImmediate (internal/timers.js:461:21)
error Command failed with exit code 1.
zeit-pkg is a tool for package nodejs code. zeit-pkg also support require('arangojs'). But zeit-pkg returned error for meet const db = require('#arangodb').db; zeit-pkg returns error.
> Error! TypeError: Cannot read property '0' of null
at shortFromAlias (/usr/local/lib/node_modules/pkg/lib-es5/walker.js:69:49)
at Walker._callee5$ (/usr/local/lib/node_modules/pkg/lib-es5/walker.js:894:25)
at tryCatch (/usr/local/lib/node_modules/pkg/node_modules/regenerator-runtime/runtime.js:62:40)
at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/pkg/node_modules/regenerator-runtime/runtime.js:296:22)
at Generator.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/pkg/node_modules/regenerator-runtime/runtime.js:114:21)
at step (/usr/local/lib/node_modules/pkg/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /usr/local/lib/node_modules/pkg/node_modules/babel-runtime/helpers/asyncToGenerator.js:30:13
at <anonymous>
I want to know what's particular in require('#arangodb').db. It's whether any replacement method exists for writing transaction. Or any other package tools can support require('#arangodb').db;
zeit-pkg is compiles JavaScript code into an executable, this is not compatible with Foxx, as Foxx is the executable that runs your JavaScript code.
If you want to minimize/uglify/mangle your code take a look at WebPack, this document from ArangoDB shows you how to get WebPack working with Foxx, as it marks those libraries as 'external' libraries that get skipped for processing.
I would like to do some test using nodejs and phantomjs inside a docker container.
All these tests work perfectly directly on a centos or debian server
npm run test
smart-tv-portal-tests#1.0.0 test /data/SmartTVPortal/tests
mocha test-*.js
test suite for
xxx
✓ should respond 200 OR 304 for xxx
(173ms)
✓ should assert that the reponse is application/json
✓ should be able to parse json
✓ should validate JSON integrity (videos.length === 6)
✓ should validate http status with phantomjs (160ms)
✓ should validate carousel is loaded (761ms)
✓ should check last carousel element
✓ should navigate interactive in the main carousel (121ms)
8 passing (1s)
but if I run the very same test within a docker container (based either on alpine/centos/ubuntu) it fails with timeout issue
docker run -ti --net=host --rm --volume /data/SmartTVPortal/:/srv --workdir /srv/tests arte/hbbtv bash
I get
bash-4.3# npm run test
smart-tv-portal-tests#1.0.0 test /srv/tests
mocha test-*.js
test suite for
xxx
✓ should respond 200 OR 304 for xxx
(2534ms)
✓ should assert that the reponse is application/json
✓ should be able to parse json
✓ should validate JSON integrity (videos.length === 6)
✓ should validate http status with phantomjs (89ms)
1) should validate carousel is loaded Unhandled rejection text evaluatePage
global code evaluateJavaScript#[native code]
evaluate#phantomjs://platform/webpage.js:390:39
phantomjs://code/bridge.js:121:61
at /srv/tests/node_modules/node-horseman/lib/actions.js:989:36
at tryCatcher (/srv/tests/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.fromNode.Promise.fromCallback (/srv/tests/node_modules/bluebird/js/release/promise.js:179:30)
at Horseman. (/srv/tests/node_modules/node-horseman/lib/actions.js:987:29)
at Horseman.tryCatcher (/srv/tests/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/srv/tests/node_modules/bluebird/js/release/promise.js:510:31)
at Promise._settlePromise (/srv/tests/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromiseCtx (/srv/tests/node_modules/bluebird/js/release/promise.js:604:10)
at Async._drainQueue (/srv/tests/node_modules/bluebird/js/release/async.js:143:12)
at Async._drainQueues (/srv/tests/node_modules/bluebird/js/release/async.js:148:10)
at Immediate.Async.drainQueues (/srv/tests/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:574:20)
at tryOnImmediate (timers.js:554:5)
at processImmediate [as _immediateCallback] (timers.js:533:5)
Unhandled rejection TimeoutError: timeout during .waitFor() after
15038 ms
at Timeout.waitForCheck (/srv/tests/node_modules/node-horseman/lib/actions.js:1643:13)
at Timeout.wrapper (timers.js:425:11)
at tryOnTimeout (timers.js:232:11)
at Timer.listOnTimeout (timers.js:202:5)
2) should check last carousel element Unhandled rejection text evaluatePage
global code evaluateJavaScript#[native code]
evaluate#phantomjs://platform/webpage.js:390:39
phantomjs://code/bridge.js:121:61
at /srv/tests/node_modules/node-horseman/lib/actions.js:989:36
at tryCatcher (/srv/tests/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.fromNode.Promise.fromCallback (/srv/tests/node_modules/bluebird/js/release/promise.js:179:30)
at Horseman. (/srv/tests/node_modules/node-horseman/lib/actions.js:987:29)
at Horseman.tryCatcher (/srv/tests/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/srv/tests/node_modules/bluebird/js/release/promise.js:510:31)
at Promise._settlePromise (/srv/tests/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromiseCtx (/srv/tests/node_modules/bluebird/js/release/promise.js:604:10)
at Async._drainQueue (/srv/tests/node_modules/bluebird/js/release/async.js:143:12)
at Async._drainQueues (/srv/tests/node_modules/bluebird/js/release/async.js:148:10)
at Immediate.Async.drainQueues (/srv/tests/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:574:20)
at tryOnImmediate (timers.js:554:5)
at processImmediate [as _immediateCallback] (timers.js:533:5)
3) should navigate interactive in the main carousel
5 passing (30s) 3 failing
1) test suite for
xxx
should validate carousel is loaded:
Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
2) test suite for
xxx
should check last carousel element:
Error: Timeout of 7000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
3) test suite for
xxx
should navigate interactive in the main carousel:
Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
The falling part of the test is
it('should validate carousel is loaded', function(done) {
this.timeout(10000);
horseman
.open(WEBAPP_URL)
.waitFor(function() {
return document.querySelector('#loadingPanel').style.visibility === 'hidden';
}, true)
.waitFor(function() {
return document.querySelectorAll('.videosCarouselItem').length === 4;
}, true)
.then(function(res) {
done();
});
});
I guess the problem is coming from phantom not able to interpret jquery and so can't find the selector but the problem appears only within a docker container.
Problem is the same using casperjs
I've dug a little more)
The very part that 'timeout' within the docker container is
.waitForSelector('.videosCarouselItem')
.count('.videosCarouselItem')
and give me the error
Unhandled rejection TimeoutError: timeout during .waitFor() after 15059 ms
at Timeout.waitForCheck (/srv/tests/node_modules/node-horseman/lib/actions.js:1643:13)
at Timeout.wrapper (timers.js:425:11)
at tryOnTimeout (timers.js:232:11)
at Timer.listOnTimeout (timers.js:202:5)
Outside docker it's OK, I get a 4 (that's correct)
Sorry for the inconvenience, issue was linked to our tested applciation, I had to change the URL by adding some queryparam.
I don't why it was working with a browser inside windows, or phantomjs directly on a VM but not inside a docker but now it's OK.
I found the error using the snapshot feature.
Sometimes, my (large) application gives the following error:
Error: write after end
at ServerResponse.OutgoingMessage.write(_http_outgoing.js:413:15)
at ServerResponse.res.write(/nodeapp/node_modules/express/node_modules/connect/lib/middleware/compress.js:110:17)
at ServerResponse.res.end(/nodeapp/node_modules/express/node_modules/connect/lib/middleware/compress.js:116:14)
at ServerResponse.res.send(/nodeapp/node_modules/express/lib/response.js:153:8)
at fn(/nodeapp/node_modules/express/lib/response.js:797:10)
at/nodeapp/node_modules/vash/build/vash.js:2082:4
at Object.vash.loadFile (/nodeapp/node_modules/vash/build/vash.js:2070:10)
at View.vash.renderFile [as engine] (/nodeapp/node_modules/vash/build/vash.js:2078:8)
at View.render (/nodeapp/node_modules/express/lib/view.js:76:8)
at Function.app.render (/nodeapp/node_modules/express/lib/application.js:504:10)
Is there a way to find out in which line this error happend? Normally the file is mentioned in the stack trace, but not in this case. Is it even from my code or can it also be caused by vash or another module?
I am using vash v0.7.12-1.
I solved it by increasing the stacktrace limit:
Error.stackTraceLimit = 20;
I'm trying the example: https://github.com/strongloop/strong-remoting/blob/master/example/simple.js
When I invoke the curl, I get: curl: (52) Empty reply from server
and the node program exits with:
sm#valley:~/Documents/Projects/test/loopback.io/remoting$ node simple.js
/home/sm/Documents/Projects/test/loopback.io/node_modules/strong-remoting/node_modules/express/lib/router/index.js:603
return fn.apply(this, arguments);
^
TypeError: Cannot call method 'apply' of undefined
at Object. (/home/sm/Documents/Projects/test/loopback.io/node_modules/strong-remoting/node_modules/express/lib/router/index.js:603:15)
at Object.immediate._onImmediate (timers.js:348:16)
at processImmediate [as _immediateCallback] (timers.js:330:15)
Any idea what I'm missing ?
You may want to also look at https://github.com/strongloop/loopback-example-remote. It's an example of the LB remote connector, which uses strong-remoting. Not sure if it fits your use case, but AFAIK it works.