I want to access and click react-native button using xpath. I'm using Appium framework for automation testing and running android emulator.
below is my code:
React-native element:
<Button onPress={ ()=>{this.onPress , Alert.alert("Button Clicked")}}
title = "Sign in"
color="blue" />
Appium Test File:
expect(await driver.elementsByXPath("//android.widget.TextView[@text=\'Sign in']")).click();
I'm using following code with webdriver.io
const webdriverio = require('webdriverio');
const client = await webdriverio.remote(androidOptions); // you have to specify your android options
const element = await client.findElement('xpath', "//android.widget.TextView[@text='Sign in']");
await client.elementClick(element.ELEMENT);