minkphp / minkbrowserkitdriver Goto Github PK
View Code? Open in Web Editor NEWSymfony2 BrowserKit driver for Mink framework
License: MIT License
Symfony2 BrowserKit driver for Mink framework
License: MIT License
Right now code, that handles element clicking doesn't care about type
attribute value of an input/button that is clicked and is causing form submission anyway.
I think we should only allow <input type="submit" .../>
to submit a form, once clicked. I don't have any HTML reference about what in fact can submit a form, once clicked. If anybody have it, then please post it here.
Hello,
I am using sonata admin bundle and I am creating the test with behat to be sure that everything is working fine. But the problem is that when I try to add a new element using behat I get this error:
The selected node does not have a form ancestor.
The problem is because this button is out of the form but this is managed by sonata admin. So is there any way to click this button without get this error?
The submitForm
method isn't checking that given xpath belongs to form
node.
Related issue Behat/MinkSelenium2Driver#170
I have a problem. I am using request headers in authentication process in my project. In tests, I wrote custom scenario step, where I set request headers. In some time I noticed that if I have scenario with authentication and after it I have scenario without authentication, the last one fails. So, I found that the problem is in request headers, request headers from previous test are still available for current test, they are not deleted. Any advice?
We've been struggling with some submit issues for a few days. We have two buttons for submitting a form, and want to use the name/value to discriminate between which one was clicked.
When these buttons have the same name, Mink will always submit the value of the first button, regardless of which was clicked.
When these buttons have a different name, Mink throws an exception:
Exception thrown by (//html/.//input[./@type = 'submit' or ./@type = 'image' or ./@type = 'button'][(((./@id = 'Continue' or ./@name = 'Continue') or contains(./@value, 'Continue')) or contains(./@title, 'Continue'))] | .//input[./@type = 'image'][contains(./@alt, 'Continue')] | .//button[((((./@id = 'Continue' or ./@name = 'Continue') or contains(./@value, 'Continue')) or contains(normalize-space(string(.)), 'Continue')) or contains(./@title, 'Continue'))] | .//input[./@type = 'image'][contains(./@alt, 'Continue')] | .//*[./@role = 'button'][(((./@id = 'Continue' or ./@name = 'Continue') or contains(./@value, 'Continue')) or contains(./@title, 'Continue') or contains(normalize-space(string(.)), 'Continue'))])[1]
Unreachable field "flag"
The two buttons were <button name="flag" value="true">Flag</button>
and <button name="continue" value="true">Continue</button>
in this case.
Have tried the latest dev version of MinkBrowserKitDriver and BrowserKit.
When trying to fill a textbox with an XML I provide, the pasted text is not my original XML, but the XML with backslashes added before the double-quotes.
I've opened a question in StackOverflow with further info:
When a base url is configured in the Behat MinkExtension, the symfony2 driver fails to resolve the url properly as it includes the base url inside the path passed to the routing. The browser client available in Symfony HttpKernel expects to receive only the path inside the application.
Removing the base url from the configuration is not an option for me as it is required for the scenario using selenium to use javascript.
Trying to click on a button
<button type="button" id="register_register" name="register[register]" class="bt_ok">Create account</button>
the driver complains with the error:
Behat\Symfony2Extension\Driver\KernelDriver supports clicking on links and buttons only. But "button" provided
Installed from composer:
"behat/behat": "2.4.*@stable",
"behat/symfony2-extension": "*",
"behat/mink-extension": "*",
"behat/mink-browserkit-driver": "*",
"behat/mink-selenium2-driver": "*"
Just run behat, and get:
c:\develope\htdocs\chyrius>behat.bat
Fatal error: Class Behat\Mink\Driver\BrowserKitDriver contains 2 abstract method
s and must therefore be declared abstract or implement the remaining methods (Be
hat\Mink\Driver\DriverInterface::getScreenshot, Behat\Mink\Driver\DriverInterfac
e::resizeWindow) in C:\develope\htdocs\chyrius\vendor\behat\mink-browser
kit-driver\src\Behat\Mink\Driver\BrowserKitDriver.php on line 867
I have updated to 2.2.0 version and I receive this error
Fatal error: Declaration of Behat\Mink\Driver\BrowserKitDriver::visit(string $url) must be compatible with Behat\Mink\Driver\CoreDriver::visit($url) in /srv/api/vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php on line 120
With the configuration below I've noticed memory usage that seems to increase as the tests run:
After around 700 steps around 400MB had been allocated.
Seems to have been reported by other people: http://stackoverflow.com/questions/20107031/behat-eating-memory
Not sure if the responsibility of this driver to destroy or garbage collect, or if there is a bug somewhere else? Please reply back if more information needed.
After minkphp/driver-testsuite#37 was merged we've forgot about BrowserKitDriver and now build is failing
https://travis-ci.org/minkphp/MinkBrowserKitDriver/jobs/580907460
Assume the page contains:
<form ...>
<input type="text" name="name" />
<input type="SUBMIT" value="login" />
</form>
I can't use ->fillField('name', 'Wouter')
because it doesn't discover type="SUBMIT"
as a submit button. When I change it to type="submit"
, all works fine.
Original issue: Behat/Mink#572
Can we get PHP ^*8.0 support on this package?
Class Behat\Mink\Driver\BrowserKitDriver contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Behat\Mink\Driver\DriverInterface::getScreenshot, Behat\Mink\Driver\DriverInterface::resizeWindow) in /Applications/MAMP/htdocs/Symfony2/vendor/behat/mink-browserkit-driver/src/Behat/Mink/Driver/BrowserKitDriver.php
Please implement this 2 methods in BrowserKitDriver.php
MinkBrowserKitDriver/src/BrowserKitDriver.php
Line 426 in 4459adc
Even if the input types are defined as type="number"
and a number is provided, the is_string
validation will fail for these, making it impossible to set numeric values for numeric inputs. You can wrap them around quotes but I think this is a regression.
The code that "forces" inputs to be strings was introduced here: c1c3a2f
I have a simple form (symfony 2 collection type with choices):
<form action="/users" method="post" >
<div>
<label for="my_form_1">[email protected]</label>
<input type="checkbox" id="my_form_1" name="my_form[users][]" value="1" />
</div>
<div>
<label for="my_form_2">[email protected]</label>
<input type="checkbox" id="my_form_2" name="my_form[users][]" value="2" />
</div>
<input type="submit" value="Submit" />
</form>
When I check "[email protected]"
This step fails with a php error:
PHP Fatal error: Call to a member function tick() on a non-object in ...vendor/behat/mink-browserkit-driver/src/Behat/Mink/Driver/BrowserKitDriver.php on line 448
It seems that the field names are normalized to my_form[users]
. Because of that this line returns an array of both checkboxes instead of the appropriate one. The weird part is that the actual \DomNode
found by the crawler is the correct one.
Hello,
As we work for a "network" company, we need to simulate clients with different IP addresses in our functional tests.
To do that, we have written the following code :
$client->setRequestHeader("REMOTE_ADDR", $ip)
Currently, we succeeded to set this header correctly but we needed to hack the method setRequestHeader inside MinkBrowserKitDriver class because the current implementation of this method adds HTTP_
when the header is not set in $contentHeaders
array.
As REMOTE_ADDR
is a request header and as this one is not set in $contentHeaders
array, the header name is currently replaced by "HTTP_REMOTE_ADDR" by the driver... Which is not correct.
To fix this problem, we only added REMOTE_ADDR
into $contentHeaders
array and noticed that everything is working as expected :
$contentHeaders = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true, 'REMOTE_ADDR' => true);
Maybe MinkBrowserKitDriver could be upgraded with this fix, so that REMOTE_ADDR
header will be supported too ?
What do you think about this case ?
Thank you for your feedback.
src/Behat/Mink/Driver/BrowserKitDriver.php::isChecked
seems to call getValue()
, instead of actually checking for a checked
attribute. Is this correct?
<?php
$session = new \Behat\Mink\Session(new \Behat\Mink\Driver\GoutteDriver);
$session->start();
$session->getCurrentUrl();
PHP Fatal error: Call to a member function getUri() on a non-object in mink-browserkit-driver/src/Behat/Mink/Driver/BrowserKitDriver.php on line 124
Ok, another try:
<?php
$session = new \Behat\Mink\Session(new \Behat\Mink\Driver\GoutteDriver);
$session->start();
$session->getPage()->getContent();
Fatal error: Call to a member function getContent() on a non-object in mink-browserkit-driver/src/Behat/Mink/Driver/BrowserKitDriver.php on line 319
Hmm.. and another one:
<?php
$session = new \Behat\Mink\Session(new \Behat\Mink\Driver\GoutteDriver);
$session->start();
$session->getPage()->getText();
Exception thrown: Behat\Mink\Exception\DriverException
Crawler can't be initialized. Did you started driver?
Hi,
Can you tag a new version to have a release compatible with Symfony 3?
I have a test. This test set the accept-language
header . When I "visit" the page, everythings all right. But when I click the submit button, the header doesn't send.
What is the correct solution?
I set the header to the session (driver) and the client too:
$this->getSession()->setRequestHeader($name, $value);
$this->getSession()->getDriver()->getClient()->setRequestHeader($name, $value);
Add extra row to BrowserKitDriver::send()
, before send with client:
$this->client->setServerParameters($this->serverParameters);
$this->client->submit($form);
Add extra $server parameter to \Symfony\Component\BrowserKit\Client::submit()
function:
public function submit(Form $form, array $values = array(), array $server = array())
{
$form->setValues($values);
return $this->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $form->getPhpFiles(), $server);
}
and then in BrowserKitDriver::send()
:
private function submit(Form $form)
{
// ...
$this->client->submit($form, [], $this->serverParameters);
$this->forms = array();
}
\Behat\Mink\Driver\BrowserKitDriver::getText() will return text in the head section and also any json on the page that's contained in a script
tag in the HTML body. \Behat\Mink\Driver\Selenium2Driver::getText(), for example, will not return text from the head section or script tags in the body section. Given the Mink documentation states:
getText() will strip tags and unprinted characters out of the response, including newlines. So it’ll basically return the text that the user sees on the page.
I'm not sure if this is a Symfony\DomCrawler issue or not.
See for a discussion of the affects of this - https://www.drupal.org/project/drupal/issues/3175718
(Complete) Composer error:
Problem 1
- Installation request for symfony/symfony 3.0.* -> satisfiable by symfony/symfony[v3.0.0].
- behat/mink-browserkit-driver v1.3.0 requires symfony/dom-crawler ~2.3 -> satisfiable by symfony/dom-crawler[v2.3.0, v2.3.1, v2.3.10, v2.3.11, v2.3.12, v2.3.13, v2.3.14, v2.3.15, v2.3.16, v2.3.17, v2.3.18, v2.3.19, v2.3.2, v2.3.20, v2.3.21, v2.3.22, v2.3.23, v2.3.24, v2.3.25, v2.3.26, v2.3.27, v2.3.28, v2.3.29, v2.3.3, v2.3.30, v2.3.31, v2.3.32, v2.3.33, v2.3.34, v2.3.35, v2.3.4, v2.3.5, v2.3.6, v2.3.7, v2.3.8, v2.3.9, v2.4.0, v2.4.1, v2.4.10, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.4.6, v2.4.7, v2.4.8, v2.4.9, v2.5.0, v2.5.1, v2.5.10, v2.5.11, v2.5.12, v2.5.2, v2.5.3, v2.5.4, v2.5.5, v2.5.6, v2.5.7, v2.5.8, v2.5.9, v2.6.0, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.8.0].
- don't install symfony/dom-crawler v2.3.0|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.1|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.10|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.11|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.12|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.13|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.14|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.15|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.16|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.17|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.18|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.19|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.2|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.20|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.21|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.22|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.23|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.24|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.25|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.26|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.27|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.28|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.29|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.3|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.30|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.31|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.32|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.33|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.34|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.35|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.4|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.5|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.6|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.7|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.8|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.3.9|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.0|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.1|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.10|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.2|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.3|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.4|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.5|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.6|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.7|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.8|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.4.9|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.0|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.1|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.10|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.11|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.12|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.2|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.3|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.4|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.5|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.6|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.7|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.8|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.5.9|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.0|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.1|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.10|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.11|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.12|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.2|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.3|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.4|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.5|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.6|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.7|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.8|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.6.9|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.7.0|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.7.1|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.7.2|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.7.3|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.7.4|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.7.5|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.7.6|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.7.7|don't install symfony/symfony v3.0.0
- don't install symfony/dom-crawler v2.8.0|don't install symfony/symfony v3.0.0
- Installation request for behat/mink-browserkit-driver ~1.3 -> satisfiable by behat/mink-browserkit-driver[v1.3.0].
The Drupal project uses MinkBrowserKitDriver for tests and we are hoping to release Drupal 11 on Symfony 7.
Would it be possible to create a release that is compatible with Symfony 7?
Thanks
Tests added in https://github.com/Behat/Mink/pull/354 revealed inconsistency in click
method implementation, that grants any input
type ability to submit form (see related task: #29).
Moreover, the <input type="reset"/>
button now is submitting form (and fails to do so because of check in DomCrawler) instead of resetting it.
Main issue: https://github.com/Behat/Mink/issues/406
When using \Behat\Mink\Driver\BrowserKitDriver::back()
, the back function behaves differently from a real browser such as Chrome.
In a real browser, redirects are ignored when going back. In this driver, redirect are not ignored and instead followed again.
Imagine the following requests made with a browser or this driver:
A browser and this driver will now be at http://www.example.org/3.
Clicking back in the browser would take me back to http://www.example.org/1. Using back()
on the driver will take me back to http://www.example.org/2, and then again to http://www.example.org/3.
I'm a bit new to this browser driver stuff, so I hope this is the right place to report this issue. Let me know if it is unclear.
When trying to get a cookie from the driver that wasn't navigated to any page yet, it will throw an exception, because the request is not set.
if ($request === null) {
throw new DriverException('Unable to access the request before visiting a page');
}
The driver at that point is already started. I am wondering is there a proper way to prevent getting the exception? There is a private property $client
, from which I could check if request is set, but it's not accessible.
First of all, I believe the exception message is invalid english and should be "Did you started the driver?".
But more importantly, this message is very unclear and hard to debug. For instance, I got this using the Goutte driver. That doesn't need to be started. After 30 minutes debugging, I discovered I got this message because I didn't call visitPath()
.
When getFormField() tries to find form button with findFormButton() it throws ElementNotFoundException. This happens when the button have type attribute setted as "Submit" instead of "submit".
I understand that it is a stupid thing set element attributes like that example, but I gues I should report this anyway...
foreach ($xpath->query('descendant::input | descendant::button', $root) as $node) {
if ('button' == $node->nodeName || in_array($node->getAttribute('type'), array('submit', 'button', 'image'))) {
return $node;
}
}
When I added "Submit" at the in_array() function, showed above, to test, it worked. Maybe we can add a strtolower() in $node->getAttribute('type') to solve this.
Is there any way I could help? Should I send a PR? Can I drop support for old Symfony versions when things go south?
I am a strong advocate for type safety and the use of PHPStan in legacy projects. However, I encountered an issue stemming from the recent changes in the MinkBrowserKitDriver library, which introduced a breaking change in a minor version update.
The commit c1c3a2fd143e78ccfe8ec4363d42edcc46e3fdfa narrowed the type from no type
to string
for several parameters. This change was released in a minor version (2.2.0) instead of a major version, resulting in a backward compatibility (BC) break.
This change has caused test failures in downstream projects, such as Drupal core and contrib/custom modules, which previously worked with version 2.1.0 but now fail with version 2.2.0.
In Drupal core, the following test fails:
1) Drupal\Tests\.......
Behat\Mink\Exception\DriverException: Only string values can be used for a radio input.
/mnt/files/local_mount/build/vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php:415
/mnt/files/local_mount/build/vendor/behat/mink/src/Element/NodeElement.php:118
/mnt/files/local_mount/build/web/core/tests/Drupal/Tests/UiHelperTrait.php:96
/mnt/files/local_mount/build/web/core/modules/user/tests/src/Functional/UserRegistrationTest.php:136
/mnt/files/local_mount/build/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
To address this issue, Drupal core has updated its minimum requirement to >=2.2.0
and modified integer method parameters to strings to comply with the new type constraints. You can view the changes made in Drupal core here.
Using Roave/BackwardCompatibilityCheck, the following breaking changes were identified:
$ git clone https://github.com/minkphp/MinkBrowserKitDriver.git
$ cd MinkBrowserKitDriver
$ docker run --rm -v `pwd`:/app nyholm/roave-bc-check --from=v2.1.0
[BC] CHANGED: The parameter $baseUrl of Behat\Mink\Driver\BrowserKitDriver#__construct() changed from no type to a non-contravariant string|null
...
[BC] CHANGED: The parameter $xpath of Behat\Mink\Driver\BrowserKitDriver#getFormField() changed from no type to string
(Full list of changes omitted for brevity)
Releasing such significant type changes in a minor version has caused unexpected failures in dependent projects. It would be prudent to release such changes in a major version update to adhere to semantic versioning principles and avoid breaking backward compatibility.
Recommendation In the 2.x branch, trigger user level deprecations for invalid input by using trigger_error()
instead of throwing an exception.
2Drivers have very basic instructions on how to get use them, but no instructions how to contribute into them. Need to add section on CONTRIBUTING.md with details about:
The current dev-master
supports Symfony 4 components, but the latest stable (1.3.2
) does not. Any chance you could create a new release that works with Symfony 4 components?
getValue($xpath)
has this:
if ($field instanceof Field\ChoiceFormField && 'checkbox' === $field->getType()) {
$value = '1' == $value;
}
So this means the html has to have value="1"
in order to work with a checkbox. But its valid to have other values in a checkbox. And there forms that use checkboxes as alternative to multiple select element.
Likewise the isChecked($xpath)
assuming a boolean value as well. So this would also need to be changed to use the checked state.
The following does not work:
$field = $page->find('css', '.mycheckflag');
$field->check();
$isChecked = $field->hasAttribute('checked'); // Expected true but actual false
https://travis-ci.org/minkphp/MinkBrowserKitDriver/jobs/581070517
1x: Method "Symfony\Component\HttpKernel\HttpKernelInterface::handle()" will return "Response" as of its next major version. Doing the same in child class "Behat\Mink\Tests\Driver\Util\FixturesKernel" will be required when upgrading.
1x in BaseUrlTest::testBaseUrl from Behat\Mink\Tests\Driver\Custom
1x: The "Behat\Mink\Tests\Driver\Custom\TestClient" class extends "Symfony\Component\BrowserKit\Client" that is deprecated since Symfony 4.3, use "\Symfony\Component\BrowserKit\AbstractBrowser" instead.
1x in DeprecationErrorHandler::shutdown from Symfony\Bridge\PhpUnit
1x: Method "Symfony\Component\BrowserKit\Client::doRequest()" will return "object" as of its next major version. Doing the same in child class "Behat\Mink\Tests\Driver\Custom\TestClient" will be required when upgrading.
1x in DeprecationErrorHandler::shutdown from Symfony\Bridge\PhpUnit
With the latest behat/mink-browserkit-driver 1.3.4 and symfony/dom-crawler 4.4.5 there's an incompatibility that causes a fatal error in our testsuite.
We have HTML containing checkboxes with an array field name, some of them disabled - e.g.:
<input type="checkbox" name="permitted_recruiters[]" value="6620" disabled checked>
<input type="checkbox" name="permitted_recruiters[]" value="5340" disabled checked>
<input type="checkbox" name="permitted_recruiters[]" value="6639">
<input type="checkbox" name="permitted_recruiters[]" value="6672">
And we have a step that uses the standard And I check "Major Tom"
step in MinkContext
.
This has been working fine, but is now giving an Undefined offset: {number}
error from BrowserKitDriver.
The error comes from this line
As far as I can see, the issue is that BrowserKitDriver's getFieldPosition() method just enumerates all checkboxes with that name on the page.
However the latest dom-crawler release includes this commit which appears to skip over fields that are disabled hence the array indices are different.
I suspect this can be fixed by duplicating that logic so that getFieldPosition
also skips disabled fields, but it might be better to try and make it more robust so that it's not relying on matching just by the array index?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.