当使用Eclipse for Java时,我可以从网站访问数据并使用Selenium填写在线表单。我所要做的只是做WebDriver driver = new HtmlUnitDriver();
和driver.get("wwww.google.com");
和driver.findElement()
。为了做到这一点,我将进入Java Build Path,访问Libraries,然后添加外部JAR文件:selenium-server-standalone-2.39.0.jar
。使用Android从网络获取数据?
我想为Android做同样的事情,但有困难。我知道有些东西叫做Selenium for Android,但它不再被支持。现在有Selendroid。但是,尽管Eclipse的代码与Java的代码很熟悉(即,SelendroidCapabilities capa = new SelendroidCapabilities("io.selendroid.testapp:0.12.0");
,WebDriver driver = new SelendroidDriver(capa);
,WebElement inputField = driver.findElement(By.id("my_text_field"));
),但我不认为这实际上与我正在寻找的相同。我甚至尝试添加selendroid-standalone-0.12.0-with-dependencies.jar
到Android库和所有我回来是这个错误在控制台:
Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.xalan.lib.sql.SecuritySupport12$8) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
所以我的问题是:我在哪里可以去了解如何使用Android的去一个网页,检索一些数据(但实际上并没有在屏幕上打开一个网页,这是严格的背景资料)?或者,通过Android使用标识符(如id
,name
或Xpath
等)从网站获取数据的步骤是什么?
硒是一种测试套件网站上运行的功能测试。你只是想知道如何在Android应用程序中发出HTTP请求?在这种情况下,我建议查看图书馆RoboSpice(https://github.com/stephanenicolas/robospice)与Google HTTP Client的组合,以获得可靠的异步网络请求。 – darnmason 2014-10-31 15:14:37
谢谢,但我不认为这是我正在寻找的。 – user2323030 2014-10-31 23:05:53