Mink icon indicating copy to clipboard operation
Mink copied to clipboard

submit form and get resulting page?!

Open humpataa opened this issue 1 year ago • 1 comments

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 avatar Jan 22 '24 15:01 humpataa

@humpataa ,

Questions:

  1. what driver are you using?
  2. what is the HTML of the startSearch button and the actual form tag of it?

Recommendations:

  1. 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
  2. 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)
  3. wait some time until page actually reloads to perform any checks

aik099 avatar Jan 26 '24 12:01 aik099