简体   繁体   English

通过Robotium在Android应用程序中测试html5输入

[英]Testing html5 inputs in Android application by Robotium

At start i want to say sorry about my English skill. 首先,我想对我的英语水平说抱歉。 I write automated test for the hybrid Android application. 我为混合Android应用程序编写了自动化测试。 GUI of this app is written in HTML5/JS/CSS3 (with angularJS framework). 该应用程序的GUI用HTML5 / JS / CSS3(带有angularJS框架)编写。 I want to test any data form. 我想测试任何数据形式。 Form is filled with some data on the start (received from server). 表单一开始就填充了一些数据(从服务器接收)。 To enter new data I have to clear current value and enter the new one. 要输入新数据,我必须清除当前值并输入新值。 For enter new text i use: 对于输入新文本,我使用:

By element = By.cssSelector("...");
solo.waitForWebElement(element);
solo.typeTextInWebElement(element, "foo", 0);

and it works well. 而且效果很好。 I have got problems with data clear. 我在清除数据方面遇到了问题。 In the Robotium documentation i found method: 在Robotium文档中,我找到了方法:

solo.clearTextInWebElement(item);

This method cannot get index parameter (I don't know why), it only use the "By" object to catch specified element. 此方法无法获取索引参数(我不知道为什么),它仅使用“ By”对象来捕获指定的元素。 I decided to use code like: 我决定使用如下代码:

By item = By.cssSelector("input:nth-child(3)");
this.solo.waitForWebElement(item);
this.solo.sleep(3000);
this.solo.clearTextInWebElement(item);

but still doesn't work too. 但仍然无法正常工作。 I don't know how to test web inputs by Robotium. 我不知道如何通过Robotium测试Web输入。

If the web elements have name or id attributes then you can use By.id("elementId") or By.name("elementName") to access them. 如果Web元素具有名称或ID属性,则可以使用By.id(“ elementId”)或By.name(“ elementName”)来访问它们。

Your question will be easier to answer if you post more sample code, particularly the html of the elements you're trying to test. 如果您发布更多示例代码,尤其是您要测试的元素的html,则将更容易回答您的问题。

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

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