johntitus / node-horseman

Run PhantomJS from Node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

not able to provide text to input with dynamic value

anuragvijayvergia opened this issue · comments

Hi I have use case where the value in the textbox is dynamic, something similar to otp , so I will get that value after running horseman till certain step for e.g. till I enter the phone number and click on generate password. I need to read that password dynamically i.e from store, below is my sample implementation
horseman
.userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0')
.open('https://www.xyz.com')
.type('input[name="mobilenumber"]', 1234567890)
.click('a[href="login.php"]')
.wait(30000)
.type('input[name="password"]', Util.getPassword('somereqid'))
.click('a[href="submit.php"]')
.wait(400)
.screenshot('./testValue.png')
.close();

getting the following error while doing this

Unhandled rejection TypeError: Object [object Undefined] has no method 'split'
at ensureMethod (/Users/anurag/Documents/Boolean-Labs/loanzen/car-check/node_modules/bluebird/js/release/call_get.js:75:15)
at Array.eval (eval at makeMethodCaller (/Users/anurag/Documents/Boolean-Labs/loanzen/car-check/node_modules/bluebird/js/release/call_get.js:18:12), :7:13)
at Array.tryCatcher (/Users/anurag/Documents/Boolean-Labs/loanzen/car-check/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/anurag/Documents/Boolean-Labs/loanzen/car-check/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/anurag/Documents/Boolean-Labs/loanzen/car-check/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/anurag/Documents/Boolean-Labs/loanzen/car-check/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/anurag/Documents/Boolean-Labs/loanzen/car-check/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/Users/anurag/Documents/Boolean-Labs/loanzen/car-check/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Users/anurag/Documents/Boolean-Labs/loanzen/car-check/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/anurag/Documents/Boolean-Labs/loanzen/car-check/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
at processImmediate [as _immediateCallback] (timers.js:582:5)

what I have observed the call to Util.getPassword('somereqid') function is made as soon as the horseman starts, I want to make this call after .wait(30000) . is there anyway this can be done by horseman ?

Was there a solution to this?

I wasn't getting this and then I cleared out my node_modules and now I am getting it.