【问题标题】:Is there a way to log found values in Detox?有没有办法在 Detox 中记录找到的值?
【发布时间】:2021-08-26 14:38:25
【问题描述】:

我正在尝试调试一些排毒测试,我有一些如下断言:

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, layout-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}

【问题讨论】:

    标签: javascript end-to-end detox


    【解决方案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');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-14
      • 1970-01-01
      • 2022-10-20
      • 1970-01-01
      • 2012-01-31
      • 2017-12-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多