Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

How do I get a React Native TextInput by its testID in an ios UITest

$
0
0

I'm trying to edit the text of a TextInput React Native component in an ios UITest. I've added the testID prop to the component.

Two questions:

  1. Where does the testID prop appear in the native ios code?
  2. How can I select the TextInput by this testID and add text to it?

App.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>  );}

TestappUITests.swift

import XCTestclass TestappUITests: XCTestCase {    ...    func testExample() {        // UI tests must launch the application that they test.        let app = XCUIApplication()        app.launch()        // Write test code here    }}

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>