【问题标题】:How to add an id to a native ios screen如何将 id 添加到本机 ios 屏幕
【发布时间】:2018-05-29 15:15:53
【问题描述】:

我在混合应用上使用 detox。我想在本机代码中使用 by.id

目前我是这样登录的:

  try {
// 'Email address' is the input's placeholder text
await waitFor(element(by.text('Email address')).atIndex(0))
  .toBeVisible()
  .withTimeout(TIMEOUT);
await expect(element(by.label('Email address')).atIndex(0)).toBeVisible();
await element(by.label('Email address')).atIndex(0).typeText(config[email].email);
} catch (err) {
  // Email addresses get cached, so you won't find the text 'Email address' after the first login
} finally {
  await element(by.label('Password')).atIndex(0).typeText(devConfig[email].password);
  await element(by.label('Sign in')).atIndex(0).tap();
}

我想做这样的事情。

await element(by.id('email')).typeText(devConfig[email].password);
await element(by.id('password')).typeText(devConfig[email].password);
await element(by.id('login')).tap();

如何向原生 ios 输入添加 id?

【问题讨论】:

    标签: ios react-native detox


    【解决方案1】:

    testID 在 iOS 上映射到 accessibilityIdentifier。因此,如果您将其设置为所需的值,您将能够使用by.id() 匹配它。

    【讨论】:

      【解决方案2】:

      我添加了一个accessibilityLabel 并由.label 使用。 https://github.com/wix/detox/blob/master/docs/APIRef.Matchers.md

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-09-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-15
        • 2021-02-04
        相关资源
        最近更新 更多