我正在使用 TestCafe 选择器来选择元素。这是表弟孩子的复杂嵌套场景。
下面是 HTML,可以帮助您了解我上面提到的内容:
在图片中,我提到了1和2是具有孙子的父元素(具有相同的DOM)path,而另一棵树中同一父元素的孙子是<span title='John' /span>。我需要 的节点,path但需要链接,<span title='John' /span>因为所有父级都有相同的 DOM。
我不知道如何使用 TestCafe 解决这种情况。我必须使用 jQuery 吗?如果是,那么如何?我尝试了很多但无法弄清楚。
我正在使用TestCafe 0.23.3.我正在尝试验证元素是否已启用或禁用.以下是禁用元素时的HTML节点:
<button class="MuiButtonBase-root-415 MuiButtonBase-disabled-416 MuiButton-root-3719 MuiButton-text-3721 MuiButton-textPrimary-3722 MuiButton-flat-3724 MuiButton-flatPrimary-3725 MuiButton-disabled-3739" tabindex="-1" type="button" disabled=""><span class="MuiButton-label-3720">Add Person</span></button>
Run Code Online (Sandbox Code Playgroud)
以下是元素启用时的HTML节点:
<button class="MuiButtonBase-root-415 MuiButton-root-7365 MuiButton-text-7367 MuiButton-textPrimary-7368 MuiButton-flat-7370 MuiButton-flatPrimary-7371" tabindex="0" type="button"><span class="MuiButton-label-7366">Add Person</span><span class="MuiTouchRipple-root-778"></span></button>
Run Code Online (Sandbox Code Playgroud)
这是我的TestCafe代码来验证元素:
.expect(Selector('button').withText('Add Person').hasAttribute('disabled'))
.ok();
Run Code Online (Sandbox Code Playgroud)
上面的TestCafe代码传递了元素的启用/禁用状态,这是不正确的,因为预期的结果是检查元素是否被禁用.我不确定这里有什么问题.
我正在尝试使用 TestCafe 在 CircleCi 上运行浏览器测试。我遵循了这个文档。主要问题是chrome浏览器打不开。CircleCi 能够成功下载图像,因为通过了自旋环境。
我在 CircleCi 上的下一步(Container circleci/node:11.6.0-browsers)中遇到问题,这会引发错误:
$ _XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
Job was canceled
Run Code Online (Sandbox Code Playgroud)
稍后在 UI 测试步骤中抛出此错误:
$ testcafe chrome:headless uitests/tests/* -r xunit:/tmp/test-results/res.xml -e
ERROR Was unable to open the browser "chrome:headless" due to an error.
Error: Unable to run the browser. The browser path or command template is not specified.
at checkBrowserPath$ (/rp-web/node_modules/testcafe-browser-tools/lib/api/open.js:47:23)
at tryCatch (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at Generator.invoke [as _invoke] (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:334:22)
at Generator.prototype.(anonymous function) [as next] (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:105:21) …Run Code Online (Sandbox Code Playgroud) 我正在使用1.1.0版的TestCafe和3.1.0版的Testcafe-react-selector。我的目标是从节点返回文本。HTML树如下所示:
<div class="header">
<div class="title">board</div>
<div class="secondary-title">Wednesday Mar 06, 2019</div>
</div>
<div class="MuiPaper-root-9 MuiPaper-elevation2-02 MuiPaper-rounded-9 board-title-break">
<div class="board-header">
<div class="title">Text Title</div>
<div class="details">
<div>
<div>Total</div>
<div class="header-count total">2 people</div>
</div>
<div> ... </div>
<div> ... </div>
<div> ... </div>
....
</div>
Run Code Online (Sandbox Code Playgroud)
在这里,我想获取“ 2个人”文本,并验证“ 2个人”是否可见。
我尝试使用Selector,如下所示:
Selector('.header-count total > div')
Run Code Online (Sandbox Code Playgroud)
但这没有解决。
这是从REACT chrome扩展获取的同一HTML树的React Tree:
<TitleBreakdown loading={false} accountId={323}> ==$r
WithStyles(Paper) className="title-breakdown">
<Paper className="title-breakdown" component="div" elevation={2} square={false}>
<div className="MuiPaper-root-9 MuiPaper-elevation2-02 MuiPaper-rounded-9"
<div className="board-header">
<div class="title">Text Title</div>
<div class="details">
<div>
<div>Total</div>
<div class="header-count total">2 …Run Code Online (Sandbox Code Playgroud) 我正在使用TestCafe,并想确定checkbox元素是否存在。在HTML元素中,如果该复选框已被选中,则该属性checked存在,否则不存在。如何确定使用TestCafe?
我使用了TestCafe中可用的功能- .hasAttribute('checked')但返回的是undefined。
选中此复选框时,以下是HTML代码:
<input class="jss1523" tabindex="-1" type="checkbox" data-indeterminate="false" value checked>
取消选中此复选框时,这是HTML代码:
<input class="jss1523" tabindex="-1" type="checkbox" data-indeterminate="false" value>
如何使用TestCafe解决此问题?
我正在运行 TestCafe docker,希望查看浏览器,以便我知道发生了什么,并且默认情况下不以无头模式运行它。是否可以?
automated-tests browser-automation docker e2e-testing testcafe
testcafe ×6
e2e-testing ×5
javascript ×2
circleci ×1
docker ×1
html ×1
jquery ×1
node.js ×1
reactjs ×1
web-testing ×1