M
M
Maxim Medvedev2017-06-07 19:32:16
PHP
Maxim Medvedev, 2017-06-07 19:32:16

How to click on a link in a modal window in a codeception test?

There is a link on the page:

<a href="" class="confirm"><i class="fa fa-times"></i></a>

By clicking on it, a modal window appears in which:
<div class="modal-footer"><button class="confirm btn btn-flat success" type="button" data-dismiss="modal">Да, уверен</button><button class="cancel btn btn-flat danger" type="button" data-dismiss="modal">Нет, передумал</button></div>

I need to click on the first button, how to do it?
Tried options:

$I->click(Locator::firstElement('//modal-footer/button'));
$I->click('.modal-footer .success');

Doesn't help, test fails. In the second case, since
[Facebook\WebDriver\Exception\ElementNotVisibleException] element not visible

In the first
Fail Link or Button or CSS or XPath element with '(//modal-footer/button)[position()=1]' was not found.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RSav, 2017-06-08
@reimax

In the first option, it does not find the element, in the second it is still invisible, set wait or waitForElement before clicking on the modal window

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question