与贝哈特或codeception每个元素 [英] for each element with behat or codeception
本文介绍了与贝哈特或codeception每个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想测试一个网站上,有一个动态menustructure。我想通过所有菜单项循环,并运行在每一页上同一系列的测试。我们谈论的是超过100页的reguraly改变。
I want to test a website which has a dynamic menustructure. I want to loop through all menuitems and run the same series of test on every page. We're talking about 100+ pages that change reguraly.
我想与任何贝哈特或codeception做到这一点。
I would like to do this with either behat or codeception.
有谁有关于如何做到这一点的想法?
Does anybody have an idea about how to do this?
推荐答案
在使用贝哈特与水貂,你可以抓住用的findAll你的菜单项(),然后遍历它:
When using Behat with Mink, you can grab your menu items with findAll() and then iterate over it:
/**
* @When /^I run my test series for all menu items$/
*/
public function iRunMyTestSeriesForAllMenuItems() {
$result = TRUE;
$this->getSession()->visit('http://www.example.com/');
$links = $this->getSession()->getPage()->findAll('css', '#menu ul li a');
foreach ($links as $link) {
$url = $link->getAttribute('href');
if (FALSE === $this->yourTestHere($url)) {
$result = FALSE;
}
}
return $result;
}
这篇关于与贝哈特或codeception每个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文