нужный элемент не найден с помощью tabBarTestID - PullRequest
0 голосов
/ 31 октября 2019

Прежде всего, первый экран - это LoginScreen, и после входа в систему мы видим нижний навигатор.

Таким образом, я создаю нижний навигатор и устанавливаю tabBartestID в Transactions для навигации. .

const Tabs = createBottomTabNavigator(
  {
    Transactions: {
      screen: createStackNavigator(
        {
          Transactions: {
            screen: TransactionsView,
            navigationOptions: {
              header: null,
            },
          },
          QueryResult: {
            screen: QueryResultView,
            navigationOptions: {
              header: null,
            },
          },
          RegisterResult: {
            screen: RegisterResultView,
            navigationOptions: {
              header: null,
            },
          },
        },
        {
          initialRouteName: 'Transactions',
        },
      ),
      navigationOptions: {
        title: 'Transactions',
        tabBarTestID: 'Transactions',
        tabBarIcon: ({ tintColor }) => <Badge tintColor={tintColor} />,
      },
    }
}

И когда я тестирую с использованием detox, ошибка составляет Interaction cannot continue because the desired element was not found.

Трассировка стека:

    ✕ navigate to transactions (66ms)

  ● Login & Generate Keys Sequence test › navigate to transactions

    Cannot find UI element.
    Exception with Action: {
      "Action Name":  "Tap",
      "Element Matcher":  "((!(kindOfClass('RCTScrollView')) && (respondsToSelector(accessibilityIdentifier) && accessibilityID('Tab Name'))) || (((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && parentThatMatches(kindOfClass('RCTScrollView'))) && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && parentThatMatches((respondsToSelector(accessibilityIdentifier) && accessibilityID('Tab Name'))))))",
      "Recovery Suggestion":  "Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element."
    }


    Error Trace: [
      {
        "Description":  "Interaction cannot continue because the desired element was not found.",
        "Error Domain":  "com.google.earlgrey.ElementInteractionErrorDomain",
        "Error Code":  "0",
        "File Name":  "GREYElementInteraction.m",
        "Function Name":  "-[GREYElementInteraction matchedElementsWithTimeout:error:]",
        "Line":  "124"
      }
    ]

Это мой тест:

describe('Login & Generate Keys Sequence test', () => {
  // beforeEach(async () => {
  // await device.reloadReactNative()
  // device.shake();
  // })

  it('login screen should load', async () => {
    await expect(element(by.id('loginView'))).toBeVisible()
  })

  it('login screen should have slogan', async () => {
    await expect(element(by.text('Things Information Exchange'))).toBeVisible()
  })

  it('login screen should have password field', async () => {
    await expect(element(by.id('password'))).toBeVisible()
  })

  it('login screen should have login button', async () => {
    await expect(element(by.id('login'))).toBeVisible()
  })

  it('login screen should have generate keys button', async () => {
    await expect(element(by.id('generateKeys'))).toBeVisible()
  })

  it('it should tap on generate keys button', async () => {
    await element(by.id('generateKeys')).tap()
  })

  it('identity setup screen should have title', async () => {
    await expect(element(by.text('Set your Identity Up'))).toBeVisible()
  })

  it('identity setup screen should have slogan', async () => {
    await expect(
      element(
        by.text(
          'Interactively expedite revolutionary ROI after bricks-and-clicks alignments.',
        ),
      ),
    ).toBeVisible()
  })

  it('identity setup screen should have password field', async () => {
    await expect(element(by.id('newPassword'))).toBeVisible()
  })
  it('identity setup screen should have password suggestion', async () => {
    await expect(
      element(by.text('Your passphrase should be .. . . ')),
    ).toBeVisible()
  })
  it('identity setup screen should have generate keys circle', async () => {
    await expect(element(by.id('keysSpinner'))).toBeVisible()
  })
  it('identity setup screen should have copy button', async () => {
    await expect(element(by.id('copy'))).toBeVisible()
  })
  it('identity setup screen copy button should have correct text', async () => {
    await expect(element(by.text('Copy to clipboard'))).toBeVisible()
  })

  it('identity setup screen should have license agreement toggle', async () => {
    await expect(element(by.id('licenseToggle'))).toBeVisible()
  })

  it('identity setup screen should have finish button', async () => {
    await expect(element(by.text('I‘m done here'))).toBeVisible()
  })

  it('identity setup screen should input new password', async () => {
    await element(by.id('newPassword')).typeText('1234567890')
  })

  it('identity setup screen should generate keys', async () => {
    await element(by.id('keysSpinner')).tap()
    await element(by.id('keysSpinner')).tap()
  })

  // it('identity should wait for generating keys', async () => {
  // TODO: wait for 2seconds
  // await expect(element(by.text("Your keys Are generated"))).toBeVisible();
  // })

  it('identity setup screen should accept license agreement', async () => {
    await element(by.id('licenseToggle')).tap()
  })

  it('identity setup screen should tap finish button', async () => {
    await element(by.text('I‘m done here')).tap()
  })

  it('navigate to transactions', async () => {
    await element(by.id('Transactions')).tap();
  })
})

Также я пытаюсь подождать 2 секунды между прочим:

await waitFor(element(by.id('Transactions'))).toBeVisible().withTimeout(2000)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...