Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用内容描述单击按钮_C#_Android_Testing_Appium - Fatal编程技术网

C# 如何使用内容描述单击按钮

C# 如何使用内容描述单击按钮,c#,android,testing,appium,C#,Android,Testing,Appium,我对使用Appium进行C#测试还不熟悉。我能够设置一切并运行测试。 我使用UiAutomatorViewer访问了一些按钮,现在我需要单击一个按钮,但我只得到了Cont-desc.哪个FindElement(ByAndroidUIAutomator.“”)链接到Cont-desc.?我什么都试过了,但总是出错。我已尝试使用TouchAction或鼠标单击此按钮。单击();什么都没用。。。 任何帮助都很好 提前感谢:) 通过XPATH查找webelement,然后单击它,如下所示: driver

我对使用Appium进行C#测试还不熟悉。我能够设置一切并运行测试。 我使用UiAutomatorViewer访问了一些按钮,现在我需要单击一个按钮,但我只得到了Cont-desc.哪个FindElement(ByAndroidUIAutomator.“”)链接到Cont-desc.?我什么都试过了,但总是出错。我已尝试使用TouchAction或鼠标单击此按钮。单击();什么都没用。。。 任何帮助都很好

提前感谢:)


通过XPATH查找webelement,然后单击它,如下所示:

driver.FindElement(By.XPath("//android.widget.Button[@content-desc='Login']")).Click();
试试这个:

driver.FindElement(按.Name('Login'))。单击()


这是访问内容描述的方法。它基本上就是视图的名称。

这对我来说是可行的

driver.findElementByAndroidUIAutomator(“UiSelector().description(\“Login\”))。单击()

参考:

使用content desc访问元素的简单方法是

driver.findElementByName("Login").click();

重要提示:注意空格,我在查找元素时遇到问题,因为content desc中的文本在文本末尾有空格…

有人能帮我吗,我阅读了一篇关于XPath的教程,并尝试了所有方法。它总是抛出一个异常:InvalidOperationException。。