如何确定特定的排毒测试在哪个平台上运行?

问题描述

按类名使用排毒匹配器时,即by.type(className) https://github.com/wix/Detox/blob/master/docs/APIRef.Matchers.md#bytypeclassname

是否可以根据测试运行的平台(ios / android)更改类名

例如element(by.type(className))变为:

  • element(by.type('android.widget.ImageView'))在Android上
  • element(by.type('RCtimageView'))在iOS上

解决方法

使用device.getPlatform()确定当前设备平台。

文档: https://github.com/wix/Detox/blob/master/docs/APIRef.DeviceObjectAPI.md#devicegetplatform

示例: https://github.com/wix/Detox/blob/240a709c609addf8b67e2ed6b91cba1293ad76c8/detox/test/e2e/03.actions.test.js#L124