我想使用xpath访问并单击react-native按钮。我正在使用Appium框架进行自动化测试并运行android仿真器。
下面是我的代码:
反应元素:
<Button onPress={ ()=>{this.onPress , Alert.alert("Button Clicked")}}
title = "Sign in"
color="blue" />
Appium测试文件:
expect(await driver.elementsByXPath("//android.widget.TextView[@text=\'Sign in']")).click();
答案 0 :(得分:1)
我在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);