小编Wil*_*ill的帖子

如何在 ios UITest 中通过 testID 获取 React Native TextInput

我正在尝试在 ios UITest 中编辑 TextInput React Native 组件的文本。我已将testID道具添加到组件中。

两个问题:

  1. testID 属性出现在本机 ios 代码中的什么位置?
  2. 如何通过此 testID 选择 TextInput 并向其中添加文本?

应用程序.js

import React from "react";
import { StyleSheet, TextInput, View } from "react-native";

export default function App() {
  return (
    <View>
      <TextInput testID="username" placeholder="Enter your username" />
    </View>
  );
}

Run Code Online (Sandbox Code Playgroud)

TestappUITests.swift

import XCTest

class TestappUITests: XCTestCase {

    ...

    func testExample() {
        // UI tests must launch the application that they test.
        let app = XCUIApplication()
        app.launch()

        // Write test code …
Run Code Online (Sandbox Code Playgroud)

xcode ios react-native

3
推荐指数
1
解决办法
3027
查看次数

标签 统计

ios ×1

react-native ×1

xcode ×1