Java 在Robotium测试期间尝试检查android上的web内容

Java 在Robotium测试期间尝试检查android上的web内容,java,android,automated-tests,robotium,Java,Android,Automated Tests,Robotium,我的应用程序是在后台运行的服务,并对网络流量进行更改。我想用Robotium调用web源代码并检查页面进行测试。 以下是我调用web内容的代码: Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); Log.d(TAG, "Looking for text ["+expected+"] at address ["+url+"]"); getSolo().getCurrentAct

我的应用程序是在后台运行的服务,并对网络流量进行更改。我想用Robotium调用web源代码并检查页面进行测试。 以下是我调用web内容的代码:

    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    Log.d(TAG, "Looking for text ["+expected+"] at address ["+url+"]");
    getSolo().getCurrentActivity().startActivity(i);
    getSolo().waitForWebElement(By.textContent(expected), timeout, false);
以下是我尝试过但没有结果的几件事

    bool foundContent = getSolo().waitForText(expected));
    foundContent = foundContent | getSolo().getCurrentWebElements().size() > 0;
    foundContent = foundContent | getSolo().getWebElement(By.tagName("div"), 0));
当测试检查“是的,页面包含单词porn”或“否,页面包含单词porn”时,这对我来说已经足够了,但是如果可能的话,我很高兴能够访问字符串形式的整个页面代码

我的第一个问题在这里,所以我希望它可以 提前感谢您的帮助


附言:我在4.0中读到(当内容直到超时才出现时为假),但在代码中(使用4.0 jar Robotium),并且在中只有一个空白。这是他们还在研究的吗?

使用Robotium 4.1。你可以使用searchText,waitForText,waitForWebElement等。Thx的建议我找不到关于4.1版本的信息。。。我现在已经使用了Solo 4.1并试用了waitForText(“.*”+expected+“*”)、searchText(“.*”+expected+“*”)和waitForWebElement(By.textContent(expected))。即使页面在emulator上加载了该内容,Everyone也会返回false(我有页面“查找内容”示例域)