Mink
Mink copied to clipboard
submit form and get resulting page?!
Hi, new to this, but having a maybe basic question. My script successfully opens a session, loads a page, sets a certain form field to my needs. Now I did this to find the submit button to submit the form:
$page = $session->getPage();
$marke = $page->findField('marke');
$marke->setValue('stern');
$button = $page->findButton('startSearch');
$button->submit();
But what now? How do I know this has worked? How do I get the resulting page? I have tried:
$page2 = $session->getPage();
echo $session->getCurrentUrl();
But this shows the title of the first page. So my guess the submit did not work as expected. Any hint appreciated. Please advise.
@humpataa ,
Questions:
- what driver are you using?
- what is the HTML of the
startSearch
button and the actualform
tag of it?
Recommendations:
- I recommend replacing
$button->submit();
with$button->click();
, because:-
$button->submit();
will only work, for a form submit button (that works without any JavaScript) -
$button->click();
will click on the button and that's what the real user does
-
- check the page submission fact by searching for a page element, that would only be present on a successful page submit (or maybe checking the page title)
- wait some time until page actually reloads to perform any checks