webdriverio: Promise chain error
Promise chain error:
client
.url(sid.url)
.then(client.waitFor('.result', 5000))
.then(client.getValue('#SSID'))
.then(function(sid){
console.log('resolved', sid); // here gets resolved ass [].length =4
return sid; // should be a SINGLE element
})
i guess in this last promise if the would be 10 calls to webdriverio the resolved promise would have array of 10 elements.
right now i workaround this by flattening an array.
respSid = _.isArray(respSid) ? _.first(respSid) : respSid;
help is very much appreciated
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 44 (14 by maintainers)
See this would’ve been very handy to have documented and clearly visible because it changes the way you build the tests completely. Since reading this it’s been much easier to work around the problems I was having.
This sounds awesome, but it does look a lot like how the selenium-webdriver is doing it. What are the advantages in your way of doing things?
Honestly, your monadic way looks very cool, but promises are amazing as well (when they work properly). You don’t usually assign promises to a variable like that, so I’m not sure that would be a problem. With promises you simply chain all the actions you want, using intermediate steps when necessary (using a .then statement for example).
All in all I’m looking forward to your progress, would be nice to be able to help you out on this. Do you have any plans on open sourcing this during development? Or will you wait until it’s finished?
I know it’s ugly but in these cases please make use of callbacks: