React native + appium how to find an element

I am trying (too long ...) to get appium to work with native reaction, but cannot find any element.

I am using an emulator, Nexus 6, android 6.0, ubuntu, appium 1.6.0, RN 0.39.2.

I am trying to find the simplest example:

// foo.js
render () {
  return (
    <Text>foo</Text>
  )
}

// spec.js
// ... some setup ...
      driver
        .elementByAccessibilityId('foo')
          .click()

and I get ...

      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 to install: <Text accessible accessibilityLabel={ 'foo' }>foo</Text>

the same answer...

any ideas?

+6
source share
2 answers

I decided to use this solution:

<Text accessibilityLabel={ 'FOO' } testID={ 'FOO' }>some stuff here</Text>

and then in the test:

driver
  .elementByAccessibilityId('FOO')

Credit goes to @jonesdar to indicate that here

+2
source

Try installing testID={'foo'}in the text and use .elementByName('foo'), not sure if this still works, but worth a try.

0

Source: https://habr.com/ru/post/1665774/


All Articles