Skip to content

feat: Form prefill tool#43

Open
leehuwuj wants to merge 2 commits intomainfrom
feat/form-prefill
Open

feat: Form prefill tool#43
leehuwuj wants to merge 2 commits intomainfrom
feat/form-prefill

Conversation

@leehuwuj
Copy link
Collaborator

@leehuwuj leehuwuj commented Jan 8, 2025

Test case: https://docs.google.com/forms/d/e/1FAIpQLSf7zWsJkIEX_uTSvx-PUtEdrROmoXMbEZ76wzh7ZmbK5fo78w/viewform

Context data:

Tax information:
Name: Peter Parker
Address: 410 Chelsea Street Staten Island, NY 10307, USA 
Working history:
- Oscorp: 
     + Years: 2023-2024.
     + 2024 income: $20000 USD.
- The Daily Bugle:
     + Years: 2022-2024.
     + 2024 income: $3000 USD.
Declaration notes:
- He is having trouble with a declaration at 2nd Jan 2025 for the tax year 2024.

Expectation:

  • The tool is able to fill all the needed fields (text, selector, radio) using the above context data.
  • Submit the form.

@vercel
Copy link

vercel bot commented Jan 8, 2025

@leehuwuj is attempting to deploy a commit to the marcusschiesser's projects team on Vercel, but is not a member of this team. To resolve this issue, you can:

  • Make your repository public. Collaboration is free for open source and public repositories.
  • Upgrade to pro and add @leehuwuj as a member. A Pro subscription is required to access Vercel's collaborative features.
    • If you're the owner of the team, click here to upgrade and add @leehuwuj as a member.
    • If you're the user who initiated this build request, click here to request access.
    • If you're already a member of the marcusschiesser's projects team, make sure that your Vercel account is connected to your GitHub account.

To read more about collaboration on Vercel, click here.

* @param dom - The DOM to construct the input tree from
* @returns The input tree
*/
export function programmaticGetFormTree(dom: Document): string {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?
I started with programmatic way which using code to construct a form tree above. It works with normal cases but also have trouble on constructing the element label with a complex form code where the text label is at other element.
To resolve this, check the getFormNode() function below

* @param value - The value to set
* @returns true if value was set successfully, false otherwise
*/
export function inputFormValue(xpath: string, value: string): boolean {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the input task, doesn't work with selector, radio elements at the moment

value: string;
}

class FormPrefillWorkflow {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, i just reused the skeleton from our navigation tool, it could include unnecessary/dead code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is:

  1. Construct a form tree - the purpose is to reduce the dom size, construct a contextual information of the form elements along with a xpath - to reduce the issue on predicting a wrong xpath.
  2. Predict the needed fields and their values.
  3. Input the fields.
  4. Submit the form - but doesn't work now. please ignore this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant