小编Prr*_*Prr的帖子

使用同一父级的表兄弟节点从父级中选择子元素

我正在使用 TestCafe 选择器来选择元素。这是表弟孩子的复杂嵌套场景。

下面是 HTML,可以帮助您了解我上面提到的内容:

html

在图片中,我提到了12是具有孙子的父元素(具有相同的DOM)path,而另一棵树中同一父元素的孙子是<span title='John' /span>。我需要 的节点,path但需要链接,<span title='John' /span>因为所有父级都有相同的 DOM。

我不知道如何使用 TestCafe 解决这种情况。我必须使用 jQuery 吗?如果是,那么如何?我尝试了很多但无法弄清楚。

html javascript jquery automated-tests testcafe

5
推荐指数
1
解决办法
1534
查看次数

Testcafe无法确定元素是启用还是禁用

我正在使用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代码传递了元素的启用/禁用状态,这是不正确的,因为预期的结果是检查元素是否被禁用.我不确定这里有什么问题.

automated-tests web-testing e2e-testing testcafe

4
推荐指数
1
解决办法
633
查看次数

容器 circleci/node:10.14-browsers - ERROR: euid != 0,directory /tmp/.X11-unix will not be created

我正在尝试使用 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)

automated-tests node.js circleci e2e-testing testcafe

3
推荐指数
1
解决办法
1996
查看次数

使用TestCafe Selector或testcafe-react-selector对嵌套组件进行故障查找元素节点

我正在使用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)

javascript automated-tests reactjs e2e-testing testcafe

3
推荐指数
1
解决办法
376
查看次数

如何使用TestCafe确定元素属性是否存在?

我正在使用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解决此问题?

automated-tests css-selectors e2e-testing testcafe

3
推荐指数
1
解决办法
129
查看次数

有没有办法在 TestCafe docker 中运行非无头浏览器?

我正在运行 TestCafe docker,希望查看浏览器,以便我知道发生了什么,并且默认情况下不以无头模式运行它。是否可以?

automated-tests browser-automation docker e2e-testing testcafe

1
推荐指数
1
解决办法
682
查看次数