0

I am building an android application to access a website using web scraping. I want to go to a particular web page by clicking button on current web page programmatically. This is the HTML element correspond to the button click.

    form method="post" action="http://localhost/example/start.php">
    <div><input type="submit" value="Start" id="someValue1"/>
    <input type="hidden" name="name1" value="value1" /></div></form>

When I click on the button popup dialog box appears asking whether I want to go to that page or not.So I have to click on "Yes" or "No" button of popup window too.That popup dialog box appearing is caused by following code on source of webpage.

    Y.on('click', M.util.show_confirm_dialog, "#someValue1", null, 
    {"message":"Are you sure that you want to continue?","continuelabel":"Start
    ","cancellabel":null});

I tried to perform action on click button using Jsoup, HtmlUnit, Selenium programmatically. But I couldn't success.Please give me a way to do this.

user3904092
  • 45
  • 1
  • 7

1 Answers1

0

you can use the url of the webview to call javascript Android Calling JavaScript functions in WebView so, just send a command like javascript:document.getElementById("myId").onclick();

Community
  • 1
  • 1
eduyayo
  • 2,020
  • 2
  • 15
  • 35
  • I tried your method to log a web site programmatically.But It only fills the textfields from given values, does not perform click on the button.What's the wrong with my code? webView.loadUrl("javascript:"document.getElementById('username').value = '"+user+"';" +"document.getElementById('password').value = '"+pass+"';"+"document.getElementByName('submit').onclick();""};"); – user3904092 Sep 10 '14 at 04:43