使用 Codeception 单击日期日历
Clicking a Date-Calendar with Codeception
用户第一次点击到达日期,第二次点击离开日期。
这是我的代码。
//Change Arriving Date
$dateFrom = date( 'j'); // Get today's Day
$dateTo = date('j', strtotime("+2 day")); // Add x Days from now
$I->click('.js-date-view');
$I->waitForElement('.mod-3rd-level-navi__anchor');
$I->click($dateFrom);
$I->wait(1);
$I->moveMouseOver($dateTo);
$I->click($dateTo);
$I->wait(1);
//Submit
$I->click('.js-send-form.btn-primary');
测试在 $dateTO
失败,但在 $dateFrom
没有失败。
基本上它不想点击离开日期。
步骤 在 12
时失败
12. $I->moveMouseOver("11") at tests/acceptance/../../changeDetailsCest.php:42
11. $I->wait(1) at tests/acceptance/.../.../changeDetailsCest.php:41
10. $I->click("7") at tests/acceptance/.../.../changeDetailsCest.php:40
9. $I->waitForElement(".mod-3rd-level-navi__anchor") at tests/acceptance/.../.../changeDetailsCest.php:39
8. $I->click(".js-date-view") at tests/acceptance/.../.../changeDetailsCest.php:38
7. $I->wait(1) at tests/acceptance/.../.../changeDetailsCest.php:32
错误
[MalformedLocatorException] CSS or XPath locator is malformed: 11
moveMouseOver
采用与 click
.
不同的参数
click
尝试按文本查找元素 -
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. For buttons, the “value” attribute, “name” attribute, and inner text are searched. For links, the link text is searched. For images, the “alt” attribute and inner text of any parent links are searched.
moveMouseOver
不按文本搜索,您必须为其提供有效的 CSS 或 XPath 选择器。
示例:$I->moveMouseOver('#date-11')
.
如果你让它工作,你可以使用 clickWithLeftButton 方法而不是 moveMouseOver
+ click
.
的组合
用户第一次点击到达日期,第二次点击离开日期。
这是我的代码。
//Change Arriving Date
$dateFrom = date( 'j'); // Get today's Day
$dateTo = date('j', strtotime("+2 day")); // Add x Days from now
$I->click('.js-date-view');
$I->waitForElement('.mod-3rd-level-navi__anchor');
$I->click($dateFrom);
$I->wait(1);
$I->moveMouseOver($dateTo);
$I->click($dateTo);
$I->wait(1);
//Submit
$I->click('.js-send-form.btn-primary');
测试在 $dateTO
失败,但在 $dateFrom
没有失败。
基本上它不想点击离开日期。
步骤 在 12
时失败 12. $I->moveMouseOver("11") at tests/acceptance/../../changeDetailsCest.php:42
11. $I->wait(1) at tests/acceptance/.../.../changeDetailsCest.php:41
10. $I->click("7") at tests/acceptance/.../.../changeDetailsCest.php:40
9. $I->waitForElement(".mod-3rd-level-navi__anchor") at tests/acceptance/.../.../changeDetailsCest.php:39
8. $I->click(".js-date-view") at tests/acceptance/.../.../changeDetailsCest.php:38
7. $I->wait(1) at tests/acceptance/.../.../changeDetailsCest.php:32
错误
[MalformedLocatorException] CSS or XPath locator is malformed: 11
moveMouseOver
采用与 click
.
click
尝试按文本查找元素 -
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. For buttons, the “value” attribute, “name” attribute, and inner text are searched. For links, the link text is searched. For images, the “alt” attribute and inner text of any parent links are searched.
moveMouseOver
不按文本搜索,您必须为其提供有效的 CSS 或 XPath 选择器。
示例:$I->moveMouseOver('#date-11')
.
如果你让它工作,你可以使用 clickWithLeftButton 方法而不是 moveMouseOver
+ click
.