问题描述
我正在尝试在我的项目中实施一些排毒测试,但是我遇到了一些问题,无法从一个屏幕导航到另一个屏幕。基本上,我已经尝试创建一个脚本来关闭如上所述的启动屏幕,但是我不知道如何识别标签栏按钮“关闭”。
//test.e2e.js
describe('Login',() => {
it('Should open a splash screen',async () => {
await device.reloadReactNative();
await expect(element(by.text('THIS IS A SPLASH SCREEN'))).toBeVisible();
});
it('Should close splash screen',async () => {
await expect(element(by.id('close'))).toBeVisible();
await element(by.id('close')).tap();
await expect(element(by.text('Login'))).toBeVisible();
});
})
在导航道具上,我已经像这样放置了道具testID: 'close'
:
static async showModal({ options }) {
await ReactNativeNavigation.showModal({
stack: {
children: [
{
component: {
name: 'Splash Screen',},options: {
topBar: {
leftButtons: [
{
id: 'close',testID: 'close',icon: dismissIcon,// Its a 'X' image
color: 'white',],backButton: { visible: false },...options,});
}
Test Failed: 'at least 75 percent of the view's area is displayed to the user.' doesn't
match the selected view.
Expected: at least 75 percent of the view's area is displayed to the user.
Got: null
8 |
9 | it('Should close splash screen',async () => {
> 10 | await expect(element(by.id('close'))).toBeVisible();
| ^
11 | await element(by.id('close')).tap();
12 |
13 | await expect(element(by.text('Login'))).toBeVisible();
at _callee2$ (login.test.e2e.js:10:43)
at tryCatch (../node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (../node_modules/regenerator-runtime/runtime.js:293:22)
at Generator.next (../node_modules/regenerator-runtime/runtime.js:118:21)
at tryCatch (../node_modules/regenerator-runtime/runtime.js:63:40)
at invoke (../node_modules/regenerator-runtime/runtime.js:154:20)
at ../node_modules/regenerator-runtime/runtime.js:189:11
at callInvokeWithMethodAndArg (../node_modules/regenerator-runtime/runtime.js:188:16)
at AsyncIterator.enqueue (../node_modules/regenerator-runtime/runtime.js:211:13)
at AsyncIterator.next (../node_modules/regenerator-runtime/runtime.js:118:21)
这是我的splash screen和the log
解决方法
我已经使用排毒记录器解决了这个问题。 https://github.com/wix/DetoxRecorder。
使用记录器,我获取了脚本流程和测试用例中使用的相同脚本。它开始工作正常。