Skip to content
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

submit form and get resulting page?! #864

Open
humpataa opened this issue Jan 22, 2024 · 1 comment
Open

submit form and get resulting page?! #864

humpataa opened this issue Jan 22, 2024 · 1 comment

Comments

@humpataa
Copy link

humpataa commented Jan 22, 2024

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.

@aik099
Copy link
Member

aik099 commented Jan 26, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants