javascript - 有没有办法在 Detox 中记录找到的值?
问题描述
我正在尝试调试一些排毒测试,我有一些如下断言:
await expect(eventScreenMatcher.component).toExist();
await expect(eventScreenMatcher.toggleButton).toExist();
await expect(eventScreenMatcher.toggleButton).toHaveText('Add to schedule');
我相信的按钮toggleButton
在屏幕上并且有正确的文本Add to schedule
。但是 Detox 在最后一个断言上失败了。
Detox 如何确定文本是什么(它只是检查那个元素),有没有办法记录它认为的内容?
这是我目前得到的输出:
预期:(文本:是“添加到计划”并且视图具有有效的可见性=VISIBLE)得到:“ReactViewGroup{id=4605, visibility=VISIBLE, width=1300, height=139, has-focus=false, has-focusable =true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, 布局-params=android.view.ViewGroup$LayoutParams@34f98eb, tag=ToggleScheduleButton, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
解决方案
您是否尝试过使用“getAttributes()”方法?有时可能有点棘手,但我认为这将有助于解决您的问题。 https://wix.github.io/Detox/docs/api/actions-on-element/#getattributes
然后你可以尝试类似
const buttonAttributes = await eventScreenMatcher.toggleButton.getAttributes();
await jestExpect(buttonAttributes.text).toBe('Add to Schedule');
推荐阅读
- angular - ngx-quill 无法显示下拉标签
- c# - 如何过滤列表
如果它包含特定的类数据? - javascript - 如何在 java ArrayList 中实现 JavaScript Array shift()
- c# - Postsharp 6.0.28、.NET 4.7.1 和编译时出现的奇怪警告
- powershell - 需要从远程的 PowerShell 脚本执行 winrm set winrm/config/client '@{TrustedHosts="192.168.4.231"}' 命令
- selenium - 自动化 Instagram 的最有效方法是什么?
- c# - 具有相同名称的多个单选按钮需要架构
- php - 当我从 php 写入时,csv 文件中的德语变音符号出现问题
- python - 使用 Barrier Python 时程序卡住
- amazon-s3 - 在 OctoberCMS 媒体库中上传到 aws s3 的文件大小限制