繁体   English   中英

使用 Appium C# 驱动程序时如何查找复选框值?

[英]How to find checkbox value when using Appium C# driver?

我正在使用 C# Appium 驱动程序 AppiumDriver

需要获取 iOS 设备上 ShowInMarkbookLocator 的复选框值

首先我试过

   _driver.FindElement(ShowInMarkbookLocator).GetAttribute("checked") 

它返回空字符串。

然后尝试..

   _driver.FindElement(ShowInMarkbookLocator).Selected 

它给出了一个错误:

OpenQA.Selenium.WebDriverException : 未知错误(发生未知的服务器端错误。status='false'。无法完成内部方法:'elementGetProperty args: [NATIVE, xpath=(//[@text='Markbook']) [1], 0, selected]', 详细信息:无法从 'xpath=(//[@text='Markbook'])[1]' 获取属性。无法连接到设备上的应用程序)

复选框定位器 ShowInMarkbookLocator 是正确的,我可以检查它的启用值

有没有另一种方法来获取复选框值?

您可以像这样查询CheckBox.IsChecked的状态:

string state = myAppiumWebElement.GetAttribute("Toggle.ToggleState");

可能的结果

“0”未选中

选中“1”

“2”未定义(例如对于没有切换状态的元素)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM