PhoenixIntegration.Requests.follow_button
You're seeing just the function
follow_button
, go back to PhoenixIntegration.Requests module for more information.
Finds a button in conn.resp_body, acts as if the user had clicked on it, follows any redirects, and returns the resulting conn.
This is very similar to follow_link
except that it looks for button tags
as rendered by PhoenixHtml.
Parameters
conn
should be a conn returned from a previous request that rendered some html. The functions are designed to pass the conn from one call into the next via pipes.identifier
indicates which link to find in the html. Valid values can be in the following forms:"/some/path"
specify the link's href starting with a"/"
character"http://www.example.com/some/uri"
, specify the href as full uri starting with either"http"
or"https"
"#element-id"
specify the html element id of the link you are looking for. Must start start with the"#"
character (same as css id specifier)."Some Text"
specify text contained within the link you are looking for.
opts
A map of additional options:method
- method to use when requesting the path. Defaults to"get"
;:max_redirects
- Maximum number of redirects to follow. Defaults to5
;
If the link is not found in the body, follow_button
raises an error.
Example:
# click through several pages that should point to each other
get( conn, thing_path(conn, :index) )
|> follow_button( "#settings_button" )
|> follow_button( "Cancel" )
|> assert_response( path: thing_path(conn, :index) )
Button request methods that don't use the :get method
Returns the transformed conn after submitting, then following the request.
Unlike trying to follow anchor tags, Phoenix always puts the method in button tags as an attribute.
This means that if you want to match agains tags with a non-get method you can, but you don't really need to.