I am trying to fill out an HTML form, click the submit button and get a response from it.
Filling out the form works very well, but I can't figure out how to click the submit button on the page.
I am using apache httpclient libraries.
My code is:
httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(pUrl); List <NameValuePair> nvps = new ArrayList <NameValuePair>(); nvps.add(new BasicNameValuePair("filter_response_time_http", "1")); nvps.add(new BasicNameValuePair("filter_port", "80")); nvps.add(new BasicNameValuePair("filter_country", "US")); nvps.add(new BasicNameValuePair("submit", "Anzeigen")); httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); response = httpclient.execute(httpost); entity = response.getEntity();
Submit Button Code:
<input onclick="doSubmit();" id="submit" type="submit" value="Anzeigen" name="submit" />
source share