I'm just startet developing apps for android. I wrote some code, with logs into a website(which uses tons of JavaScript) and grabs some data, which i need. I used for that HtmlUnit. Now i see, that HtmlUnit doesn't work on android, so i need an alternative. I did something like this...
final WebClient webClient = new WebClient(BrowserVersion.EDGE);
webClient.getOptions().setUseInsecureSSL(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
final HtmlPage loginSite = webClient.getPage("...");
final HtmlForm login_form = (HtmlForm) loginSite.getElementById("login_form");
final HtmlSubmitInput button = (HtmlSubmitInput) login_form.getByXPath("//input[@id='login_submit_button']").get(0);
final HtmlTextInput id = login_form.getInputByName("user");
id.setValueAttribute("...");
final HtmlPasswordInput pw = login_form.getInputByName("password");
pw.setValueAttribute("...");
button.click();
webClient.waitForBackgroundJavaScript(2000);
HtmlPage worldSelectionForm = (HtmlPage) webClient.getTopLevelWindows().get(0).getEnclosedPage();
final List<HtmlAnchor> anchorlist = worldSelectionForm.getAnchors();
getWorld(anchorlist, 126).click();
webClient.waitForBackgroundJavaScript(5000);
HtmlPage game = (HtmlPage) webClient.getTopLevelWindows().get(0).getEnclosedPage();
System.out.print(game.asXml());
public static HtmlAnchor getWorld(List<HtmlAnchor> anchorlist, int world) {
HtmlAnchor anchor = null;
for (HtmlAnchor a : anchorlist) {
if (a.toString().contains("server_de" + String.valueOf(world))) {
anchor = a;
}
}
return anchor;
}
I searched alot, but didn't find the answer to my question.
Can i do this too with Selenium? Is selenium only for Testing?
Greetings