Skip to content

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

Description

@rentrop

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorwipwork in progress

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions