I've just started auto end-to-end testing with my react native app, both ios and android, context is nodejs. Client is selenium-webdriver, which connects to appium server.
According to several sources, the best way to locate an element in React Native is to supply an accessibilityLabel to a View. However, in selenium-webdriver, there's no such function like:
driver.find_elements_by_accessibility_id('some id')
Currently I'm using a workaround instead:
driver.findElement(By.xpath('//*[@accessibilityLabel="some label"]'))
As it traverses all attributes of all elements, not hard to imagine its low efficiency. What could be a better approach?
P.S. I chose selenweb driveriver as client because it's also used for testing our web app, so I don't need to go through another learning curve. But if needed, I'm happy to switch to another client.
You can do this with plain selenium webdriver like so:
driver.find_element("accessibility id", "some id")
That is basically all the helper method in the appium client is doing behind the scenes. It even works directly with WinAppDriver apart from Appium.
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