Skip to content

Wrong Submit button detected if form$fields$type is missing #159

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

Closed
rentrop opened this issue Jul 14, 2016 · 2 comments · Fixed by #161
Closed

Wrong Submit button detected if form$fields$type is missing #159

rentrop opened this issue Jul 14, 2016 · 2 comments · Fixed by #161
Labels
bug an unexpected problem or unintended behavior wip work in progress

Comments

@rentrop
Copy link
Contributor

rentrop commented Jul 14, 2016

Taking this example form:

require(rvest)
ses <- html_session("https://www.handelsregister.de/rp_web/mask.do?Typ=e")
form <- ses %>% html_form() %>% .[[1]]
submit_form(ses, form, submit = 'foo')

submit_form exits with the error

Error: Unknown submission name 'foo'.
Possible values: bundeslandTH, schlagwortOptionen, ort

Looking at the form all three "Possible values" are no submit-buttons:

<input checkbox> 'bundeslandTH':
<input radio> 'schlagwortOptionen':
<input text> 'ort':

digging into submit_form and submit_request it turns out that there are form$fields that do not have a form$fields$type.

rvest:::submit_request reads as follows:

is_submit <- function(x) tolower(x$type) %in% c("submit", 
    "image", "button")
  submits <- Filter(is_submit, form$fields)
  if (length(submits) == 0) {
    stop("Could not find possible submission target.", call. = FALSE)
  }
...

As the form$fields$type is missing is_submit returns logical(0) which is not at all handled by Filter

@bramtayl
Copy link

bramtayl commented Sep 15, 2016

@rentrop
Copy link
Contributor Author

rentrop commented Oct 12, 2016

@hadley hadley added bug an unexpected problem or unintended behavior wip work in progress labels Mar 17, 2019
hadley pushed a commit that referenced this issue Mar 29, 2019
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 wip work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants