-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Conversation
Add form input manipulation and wait for results overlay to appear.
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'); |
There was a problem hiding this comment.
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');
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
Maybe the discussion for modifying the function names should be put into a new issue? |
Closing as it's now possible to just use the standard BrowserKit methods. |
Add form input manipulation and wait for results overlay to appear as per #41