getgauge / taiko

A node.js library for testing modern web applications
https://taiko.dev
MIT License
3.57k stars 453 forks source link

taiko not able to switchTo new window opened as part of test #1590

Closed l-alladi closed 3 years ago

l-alladi commented 3 years ago

My code looks like this: await button({id : 'lookup.incident.assignment_group'},{navigationTimeout:10000}).exists() await click(button({id : 'lookup.incident.assignment_group'},{navigationTimeout:10000}),{selectHiddenElements: true}) waitFor(10000) await switchTo('ServiceNow – Google Chrome')

after await click(button({id : 'lookup.incident.assignment_group'},{navigationTimeout:10000}),{selectHiddenElements: true}) new window(not tab) opens with tittle 'ServiceNow – Google Chrome'

Taiko not able to switch to this window and select text, displays below error:

Error Message: Error: No tab(s) matching ServiceNow – Google Chrome found Stacktrace: Error: No tab(s) matching ServiceNow – Google Chrome found at module.exports.switchTo (node_modules\taiko\lib\taiko.js:425:13) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:97:5) at async module.exports. (node_modules\taiko\lib\taiko.js:3266:14) at async Object. (tests\incident.js:892:3)

NivedhaSenthil commented 3 years ago

switchTo doesn't seem to be accepting string to do an action...for a moment can you please try using a regex like await switchTo(/ServiceNow – Google Chrome/)

l-alladi commented 3 years ago

yes, using regular expression helped. thanks @NivedhaSenthil

zabil commented 3 years ago

switchTo only supports regular expressions now. This the documentation was updated a while ago to reflect this https://docs.taiko.dev/api/switchto/