automated tests - Get link from text input field and then open it with DalekJS -
i have issue link need traverse using dalekjs not clickable, rather copy/pastable. how can retrieve value input field in browser , use in test.open() call?
<table> <tbody> <tr> <td>link 1</td> <td><input type="text" value="http://example.com/link-1" class="start-link"></td> </tr> <tr> <td>link 2</td> <td><input type="text" value="http://example.com/link-2" class="start-link"></td> <tr> </table>
in example above dalekjs dynamically run test.open('http://example.com/link-1');
during progression of test.
module.exports = { 'a test case': function (test) { test.open('http://example.com/example-from-above.html') .open('http://example.com/link-1') //this link i'm trying retrieve dynamically. .screenshot('image.png') .done(); } }
how can accomplish this?
dalekjs not allow reading values of html element synchronously , using them in test scripts. if need interact content of testing page, execute
method may help.
you can try setting window location function "executed in browser":
module.exports = { 'a test case': function (test) { test.open('http://example.com/example-from-above.html') // open url first input element value .execute(function () { var input = document.queryselectorall('.start-link')[0]; location = input.value; }) // wait until browser opens page .waitfor(function () { return location.pathname.indexof('link-1') > 0; }) .screenshot('image.png') .done(); } }