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

Provide partial named selector that selects also the hidden fields #711

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/Selector/PartialNamedIncludingHiddenSelector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of the Mink package.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Behat\Mink\Selector;

/**
* Named selectors engine. Uses registered XPath selectors to create new expressions.
*
* @author Konstantin Kudryashov <[email protected]>
*/
class PartialNamedIncludingHiddenSelector extends PartialNamedSelector
Copy link
Member

Choose a reason for hiding this comment

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

How you plan to use this selector, e.g. during scenario writing for Behat?

Copy link
Author

@claudiu-cristea claudiu-cristea Jul 18, 2016

Choose a reason for hiding this comment

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

Well, we need this in Drupal testing framework, see https://www.drupal.org/node/2767655. As you can see there, we init the session by registering also this new selector to the SelectorsHandler:

    $selectors_handler = new SelectorsHandler([
      'named_partial_including_hidden' => new PartialNamedIncludingHiddenSelector()
    ]);
    $session = new Session($driver, $selectors_handler);

Then we have an extension of WebAssert and override fieldExists() and fieldNotExists() to use also this new selector.

I was not thinking how this can be used in Behat scenarios. Probably that could be a follow up task?

{
public function __construct()
{
$this->registerReplacement('%notFieldTypeFilter%', "not(%buttonTypeFilter%)");
Copy link
Member

Choose a reason for hiding this comment

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

Name doesn't really say that hidden fields are allowed.

Copy link
Author

Choose a reason for hiding this comment

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

PartialNamedIncludingHiddenFieldsSelector would be better?

Copy link
Member

Choose a reason for hiding this comment

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

No, I've meant notFieldTypeFilter and buttonTypeFilter doesn't mention hidden fields in any way.

Copy link
Author

@claudiu-cristea claudiu-cristea Jul 18, 2016

Choose a reason for hiding this comment

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

Well, I cannot rename that because, in fact, I'm overriding there the existing %notFieldTypeFilter% replacement.


parent::__construct();
}
}