I'm trying (for too long...) to get appium working with react native, but can't seem to find any element.
I'm using an emulator, Nexus 6, android 6.0, ubuntu, appium 1.6.0, RN 0.39.2.
I'm trying to get the most basic example to work:
// foo.js
render () {
return (
<Text>foo</Text>
)
}
// spec.js
// ... some setup ...
driver
.elementByAccessibilityId('foo')
.click()
and I'm getting...
1) should be able to find 'Buttons' and click it
0 passing (13s)
1 failing
1) Android find and click should be able to find 'Buttons' and click it:
Error: [elementByAccessibilityId("foo")] Error response status: 7, , NoSuchElement - An element could not be located on the page using the given search parameters. Selenium error: An element could not be located on the page using the given search parameters.
I also tried setting:
<Text accessible accessibilityLabel={ 'foo' }>foo</Text>
same response ...
any ideas?
Finding elements using the ID is, by far the simplest technique. Each element has a unique ID assigned to it that helps in identifying and interacting with it. Appium has a Native element identifier for Android and iOS. resource-id is used as an element identifier for Android and name is used for iOS.
Appium Inspector allows you to perform tests on real mobile devices in app testing scenarios, such as writing mobile test scripts with Appium Inspector to identify objects easily. This has provided ample reasons for teams to use real Android and iOS devices to perform testing.
In order to tap on a found image element, Appium has to use one of its touch action strategies. The available strategies are the W3C Actions API, or the older MJSONWP TouchActions API. Stick to the default unless the driver you are using does not support the W3C Actions API for some reason.
I ended up using this solution:
<Text accessibilityLabel={ 'FOO' } testID={ 'FOO' }>some stuff here</Text>
and then in the test:
driver
.elementByAccessibilityId('FOO')
Credit goes to @jonesdar for pointing that out here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With