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

added example to populate text input #43

Closed
wants to merge 2 commits into from

Conversation

ChangePlaces
Copy link
Contributor

Add form input manipulation and wait for results overlay to appear as per #41

Add form input manipulation and wait for results overlay to appear.
@ChangePlaces
Copy link
Contributor Author

I added the code to the example file also

@@ -42,6 +42,13 @@ $crawler = $client->click($link);
// Wait for an element to be rendered
$client->waitFor('.support');

// populate the search box with some search text - this will trigger a search box overlay to appear with results
$client->findElement(WebDriverBy::cssSelector('.search__input.ds-input'))
->sendKeys('how');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just asking: is mandatory to use sendKeys() as the method name because it comes from some external library ... or did we define this method ourselves? I'm asking because "send keys" looks like taking the keys out of your keyboard, putting them in a box and sending them somewhere. The word that we're looking for is probably type.

Also, a word about the DX of the proposed API: it looks too low-level and verbose. Example:

// Panthere
$client->findElement(WebDriverBy::cssSelector('.search__input.ds-input'))->sendKeys('how');

// Laravel's Dusk
$browser->type('.search__input.ds-input', 'how');

// it's also possible to find elements by name, not only CSS selector
// $browser->type('search', 'how');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value of findElement is a WebDriverElement, i.e. something coming from an external lib

Copy link
Member

@dunglas dunglas Jul 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, and the Facebook's lib just reuse the W3C/Selenium terms. However, we should be able to use the BrowserKit API directly:

$form = $client->filter('.search form')->form();
$form['search']->setValue('my search terms');

$client->submit($form);

I've not tested it, but if it works with BrowserKit, it works with Panthère).

Anyway, we can add new helper methods, but we should provide them in BrowserKit directly (the idea behind Panthère is too be able to use BrowserKit or Goutte or a real browser with the exact same code, and maybe some conditions for the waits for instance).

@ChangePlaces
Copy link
Contributor Author

Maybe the discussion for modifying the function names should be put into a new issue?

@dunglas
Copy link
Member

dunglas commented Oct 2, 2020

Closing as it's now possible to just use the standard BrowserKit methods.

@dunglas dunglas closed this Oct 2, 2020
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

Successfully merging this pull request may close these issues.

None yet

5 participants