Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

submission_build function creates a faulty submission, checking all boxes #316

Open
oganm opened this issue Mar 24, 2021 · 0 comments
Open
Labels
bug an unexpected problem or unintended behavior form 🧾

Comments

@oganm
Copy link

oganm commented Mar 24, 2021

I am trying to fill the web form in this website using html_form, html_form_set and html_form_submit. This does not work due to the way submission_build function fills the checkboxes. The form below should be filled correct and return a table but it returns an error page instead due to some checkboxes being marked erroneously.

Minimal example:

httr::set_config(httr::config(ssl_verifypeer = 0L))
session = rvest::session('https://www.flyrnai.org/cgi-bin/DRSC_orthologs.pl')
form = rvest::html_form(session)[[1]]
form = rvest::html_form_set(form,
                             input_species = 9606,
                             output_species = 10090,
                             gene_list = "GZMH")

response = rvest::html_form_submit(form,submit = 'submit')

# the results will be missing here
response %>% 
        xml2::read_html() %>% 
        rvest::html_node('#results')

# debugging ---
writeLines(as.character(session$response),'page.html')
utils::browseURL('page.html')

writeBin(response$content,'response.html')
utils::browseURL('response.html')

Examining the session and response outputs above we will see that all the checkboxes are checked during the submission process

Examining the root cause of the issue I find that it is the way submission_build function handles these checkboxes

Looking within html_form_submit It seems like it uses the pair, submission_build and submission_submit functions to do it's work and submission_build function simply extracts the value object from the form form fields and send them off the be checked. However the actual information about the state of these fields are stored elsewhere in the attr. For example

additional_filters = which(names(form$fields) == 'additional_filter')
additional_filter_names = form$fields[additional_filters] %>% purrr::map_chr('value')
form$fields[additional_filters][additional_filter_names %in% 'NoLow'][[1]]$attr$checked
@hadley hadley added bug an unexpected problem or unintended behavior form 🧾 labels Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior form 🧾
Projects
None yet
Development

No branches or pull requests

2 participants