Skip to content

Commit 75894bd

Browse files
authored
docs(detox): add information about testID in {N} 8.2 (#244)
1 parent 6c9f360 commit 75894bd

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

packages/detox/README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ Open `.detoxrc.json` and make the following modifications under `apps` and `devi
8282

8383
- `build`: Specify the build command for iOS and Android.
8484

85-
- iOS: `ns build ios`
86-
- Android: `ns build android --detox`
85+
- iOS: `ns build ios --env.e2e`
86+
- Android: `ns build android --detox --env.e2e`
8787

8888
- `devices`:
8989
- iOS: `"type": "iPhone 11"`
@@ -137,18 +137,6 @@ Here is a full example of a Detox configuration:
137137

138138
> **Note:** A default NativeScript Android project uses 17 as the minimum SDK, but Detox requires >=21. Remove or modify the `minSdkVersion` in your `App_Resources/Android/app.gradle`.
139139
140-
### Add Resource ID (**Android Only**)
141-
142-
In order to use the `automationText` property in NativeScript it must be enabled by adding a custom resource ID.
143-
144-
Create a file called `ids.xml` in `App_Resources/Android/src/main/res/values/` and add the following:
145-
146-
```xml
147-
<?xml version="1.0" encoding="utf-8"?>
148-
<resources>
149-
<item type="id" name="nativescript_accessibility_id"/>
150-
</resources>
151-
```
152140

153141
### Allow Local Networking (**iOS Only**)
154142

@@ -186,12 +174,12 @@ This example creates a testing scenario called `Example` and has a single test i
186174

187175
Detox uses [matchers](https://github.com/wix/Detox/blob/master/docs/APIRef.Matchers.md) to find elements in your UI to interact with.
188176

189-
You can use NativeScript's `automationText` property to find your UI elements using Detox's `by.id()` matcher.
177+
You can use [NativeScript's `testID` property](https://blog.nativescript.org/nativescript-8-2-announcement/#testid) to find your UI elements using Detox's `by.id()` matcher.
190178

191179
Example:
192180

193181
```xml
194-
<Button text="Tap Me!" automationText="testButton"></Button>
182+
<Button text="Tap Me!" testID="testButton"></Button>
195183
```
196184

197185
```javascript
@@ -267,6 +255,22 @@ Manifest merger failed : uses-sdk:minSdkVersion 17 cannot be smaller than versio
267255
Command ./gradlew failed with exit code 1
268256
```
269257
258+
---
259+
260+
### Elements can not be found during test
261+
In NativeScript <8.2, the `testID` property was not available. Instead, you were supposed to use the `automationText` property.
262+
263+
**Add Resource ID (**Android Only**) **
264+
In order to use the `automationText` property in NativeScript it must be enabled by adding a custom resource ID.
265+
Create a file called `ids.xml` in `App_Resources/Android/src/main/res/values/` and add the following:
266+
267+
```xml
268+
<?xml version="1.0" encoding="utf-8"?>
269+
<resources>
270+
<item type="id" name="nativescript_accessibility_id"/>
271+
</resources>
272+
```
273+
270274
## License
271275
272276
Apache License Version 2.0

0 commit comments

Comments
 (0)