Automated tests 从文本输入字段获取链接,然后用DalekJS打开它
我有一个问题,我需要使用DalekJS遍历的链接是不可点击的,它相当于可复制/可复制的。如何从浏览器中的输入字段中检索值,然后在test.open()调用中使用它Automated tests 从文本输入字段获取链接,然后用DalekJS打开它,automated-tests,dalekjs,Automated Tests,Dalekjs,我有一个问题,我需要使用DalekJS遍历的链接是不可点击的,它相当于可复制/可复制的。如何从浏览器中的输入字段中检索值,然后在test.open()调用中使用它 如何实现这一点?DalekJS不允许同步读取HTML元素的值并在测试脚本中使用它们。如果您需要与测试页面的内容交互,该方法可能会有所帮助 您可以尝试通过“在浏览器中执行”功能设置窗口位置: <table> <tbody> <tr> <td>
如何实现这一点?DalekJS不允许同步读取HTML元素的值并在测试脚本中使用它们。如果您需要与测试页面的内容交互,该方法可能会有所帮助 您可以尝试通过“在浏览器中执行”功能设置窗口位置:
<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>
module.exports = {
'A test case': function (test) {
test.open('http://example.com/example-from-above.html')
.open('http://example.com/link-1') //This is the link I'm trying to retrieve dynamically.
.screenshot('image.png')
.done();
}
}
module.exports = {
'A test case': function (test) {
test.open('http://example.com/example-from-above.html')
// Open the URL from the first input element value
.execute(function () {
var input = document.querySelectorAll('.start-link')[0];
location = input.value;
})
// Wait until the browser opens the page
.waitFor(function () {
return location.pathname.indexOf('link-1') > 0;
})
.screenshot('image.png')
.done();
}
}