I use Behat to test a third-party online store. I have an item in my shopping cart that I want to delete. A confirmation pop-up window shows that it asks me if I really want to do this. The structure of this dialog box is as follows:
<div> <strong class="title">Remove item from shoppingcart</strong> <p>Are you sure you want to delete this product?</p> <div class="button-container"> <span class="button" data-confirm="true">Yes</span> <span class="button alt right" data-mfp-close-link="true">No</span> </div> </div>
I was able to select a range using xpath with the following code:
public function iConfirmTheWindow() { $session = $this->getSession(); $element = $session->getPage()->find( 'xpath', $session->getSelectorsHandler()->selectorToXpath('css', 'span.button') ); if (null === $element) { throw new \InvalidArgumentException(sprintf('Could not find confirmation window')); } $element->click(); }
The selection works, but Behat can't seem to click the spacebar.
supports clicking on links and submit or reset buttons only. But "span" provided
I need to click this element, how can I rewrite my function so that it can be clicked?
source share