2016년 11월 16일 수요일

How to automatically fill fields in a web page's form (when loaded in a webview)


Hi there, I'm taking a crack at my first app. One paper, it's pretty simple, and I've got most of the interface and basic logic figured out, but I'm stuck on one key step that might require an extension of some kind.

My app is pretty simple, it's for making it easy to enter the ticket lottery of a Broadway show. Normally you have to go to a webpage, click a link, and a form is opened in an iframe prompting you for your name, date of birth, etc. I'd like to have an app that stores my name, etc in TinyDB, and then opens the page in a webview. Once it loads the form, I want the fields to automatically be populated by the appropriate entries in TinyDB. If this is confusing, there's a free iOS app that does almost exactly this called Ham (https://itunes.apple.com/us/app/ham-lottery-app/id1088026752?mt=8)

Now, I can store the data easily in TinyDB through a settings screen that prompts for the various values. And I can see the class and IDs for each input field in the web page. But I don't see any obvious way to tell the app to put a TinyDB value into the corresponding an html input element when the iframe loads (or for that matter to get it to notice that the iframe has loaded). Any ideas how to accomplish this?

Thank you!

-- 
How to automatically fill fields in a web page's form (when loaded in a webview)
unfortunately that's not possible
but probably you can create your own screen using App Inventorcomponents and use the web component to send the data, as it is done in this example https://puravidaapps.com/spreadsheet.php

Taifun

-- 
Hi Taifun, thanks for the quick answer. One question about the approach you suggest:

The form I'd like to submit data to includes a Google reCAPTCHA element. The iOS app I reference fills out all the other fields automatically, then has the user handle the CAPTCHA manually. Do you see a way for the user to handle CAPTCHA using the method you're suggesting?

-- 
see this stackoverflow answer http://stackoverflow.com/a/26387263/1545993
Taifun

-- 
to prefill some fields on a webpage using the webviewer probably might be possible for older devices (API < 19), see also http://stackoverflow.com/a/13346730/1545993and http://stackoverflow.com/a/32115462/1545993

this is what the GoToUrl method is doing (copied from the sources)

  /**
   *  Load the given URL
   */
  @SimpleFunction(
      description = "Load the page at the given URL.")
  public void GoToUrl(String url) {
    webview.loadUrl(url);
  }


Taifun


-- 
I now found a solution, which runs fine on Android 7...
Enjoy!

Taifun

-- 
Awesome, thank you so much for not only considering the response, but creating a page dedicated to a detailed answer! This is above and beyond. I will take a crack at this right away.

-- 

It works great! Thank you again so much! There's only one snag I've run into and it's quite minor. I've figured out how to use this to fill in text fields and to select values for drop-down menus. There's just one checkbox I can't figure out how to automatically check (not the recaptcha, just a normal <input type="checkbox">). I'll look around and post if I find a solution, but does anyone else have any ideas?



-- 

댓글 없음:

댓글 쓰기