Comments (7)
I'm going to close as this seems like a niche feature that can be achieved with a custom browser or component. If there is future interest in this we can revisit.
from browser.
Update to the above - this actually has uncovered a wider application. I am trying to simulate submitting a form with a form collection, and the JS to add collection items is unavailable.
Using e.g. Codeception I am able to simply specify what the form fields would be if I had added several items to the collection, and then submit these.
This is the same case as above for the select with autocomplete - instead of wanting to fill in form fields directly, we need a general way to manipulate the form data that is send when the form submit click is simulated.
from browser.
I have a working solution for the autocomplete field which is not very elegant but seems to work.
->use(function(AbstractBrowser $browser, Crawler $crawler)
{
$form = $crawler->selectButton('Next Step')->form();
$form['customer']->disableValidation()->select('1234');
$browser->submit($form);
})
I don't think the callback function(AbstractBrowser $browser, Crawler $crawler)
is documented but it works.
from browser.
Interesting solution. You could probably wrap that up into a dynamic custom browser method.
from browser.
I've done exactly that.
// AppBrowser
public function selectAutocompleteField(string $formButtonName, string $selector, string $value): self
{
return $this->use(function(AbstractBrowser $browser, Crawler $crawler) use ($formButtonName, $selector, $value)
{
$form = $crawler->selectButton($formButtonName)->form();
$form[$selector]->disableValidation()->select($value);
$browser->submit($form);
});
}
It would be good if I didn't need to pass the form name...
from browser.
What about:
public function selectAutocompleteField(string $selector, string $value): self
{
return $this->use(function(AbstractBrowser $browser, Crawler $crawler) use ($formButtonName, $selector, $value)
{
$form = $crawler->filter(\sprintf('[name="%s"]', $selector))->ancestors()->filter('form')->form();
$form[$selector]->disableValidation()->select($value);
$browser->submit($form);
});
}
from browser.
Yep - that's a great improvement thanks!
from browser.
Related Issues (20)
- Issues with HttpPlug mock client HOT 13
- Replacing some service in container + validate form HOT 3
- Support for testing CSV responses HOT 9
- Unexpected behaviour for assertSeeIn() HOT 6
- Json::assertHas doesn't work as expected HOT 23
- Add compatibility with PHPUnit 10.* HOT 9
- Improve file saving HOT 3
- Panther js console log assertions
- feat: `click()` with method (`KernelBrowser`)
- Confusing `assertJsonMatches` exception message when arrays are equal but not same HOT 4
- RFC: Extension for behat HOT 4
- Add Symfony 7 to test matrix HOT 1
- Doctrine deprecation warnings HOT 1
- POST json relations are arrays instead of objects
- Crawler is detached from the form fill helpers HOT 3
- fill a form, listen for page-changing events HOT 10
- Configure screenshots_dir in code, expose savedScreenshots HOT 2
- How to access Session variable HOT 4
- Fix deprecations in tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from browser.