【发布时间】:2020-10-05 03:54:04
【问题描述】:
我正在尝试使用 Appium 编写一些测试代码,但遇到了无法设置 android.widget.CheckedTextView 对象的检查值的情况。请参考下图。我想以编程方式选择 Alpha Option 1。我试过下面的代码sn-p,但不出所料,这行不通。
@When("I select Alpha option {int}")
public void i_select_Alpha_option(Integer int1) {
// This coding needs to be completed
// This is not the right way to select or change the value of a checkedTextView
driver.findElementByXPath("//android.widget.CheckedTextView[@text='Alpha Option 01']").click();
}
由于对象类型(CheckedTextView)不可点击,代码将不起作用。
问题是,我如何使用 findElementByXpath 或任何其他方法来更改当前选定的
“查理选项 03” 至 Alpha 选项 01 或 Beta 选项 02 就此事而言
只要给我指出正确的方向。
非常感谢。
【问题讨论】:
-
你好,CheckedTextView 不可点击是什么意思。你目前无法通过代码点击它或手动它不可点击??
-
通过在上面的 sn-p 中使用 click,我无法将单选按钮的默认值更改为 Alpha Option 01
-
您确定定位器(XPath) 是准确且唯一的吗? - 尝试打印它的值以确保你想要的元素 - 尝试更改为 text() - 尝试 driver.findElement(By.xpath(""))
-
是的,在这种情况下,定位器 (Xpath) 是准确且唯一的。改成 text() 是什么意思?
-
hmm @text->text(),只是网络上的语法。我仍在考虑定位器的准确性。我正在使用 Appium 检查器,而不是 UI Automator Viewer 的很多 exp,所以我不确定。所以如果它真的不可点击。让我们尝试获取坐标并单击 x 和 y 的坐标。
标签: java selenium selenium-webdriver appium