如何根据<a> using codeception?

时间:2015-12-04 06:03:33

标签: php codeception

I am writing test case using CodeCeption in drupal.

The HTML of the link is this:

<a href="#" rule_id="83" class="delete-rule">delete</a>

I want to click on this link based on this rule_id. I'll provide the rule_id to it and it will click on the corresponding delete button.

I've tried to explore something like this but not succeeded yet. Is there any way to click on this basis?

1 个答案:

答案 0 :(得分:2)

您可以使用XPath作为click()方法的参数。这适用于您的示例:

$I->click('//a[@rule_id=83]');

您可以在Codeception文档中找到更多示例:http://codeception.com/docs/03-AcceptanceTests#PHP-Browser