sna*_*ile 6 php selenium unit-testing html-table selenium-rc
我的页面上有一个表,它应该包含某个元素.我可以通过名称识别表(它有一个唯一的名称),我也可以轻松识别该元素.我想断言该元素存在于表的行r,列c上.使用Selenium命令最干净的方法是什么?
备注:
div\div\table\div\tbody\td\tr[r]\td[c]代码中的所有内容).澄清:
如果单元格中的元素只是纯文本,那么我可以像这样检索该文本:
$this->getText("xpath=//table[@name='tableName']//tr[".$r."]//td[".$c."]"); (PHP)
但是如果单元格中的元素不仅仅是纯文本呢?如果元素是link(link=anchor)或button(//button[@type='button'])或图像或更复杂的东西怎么办?
我需要声明由该元素的定位器指定的元素驻留在给定的单元格中.
听起来像你想要的isElementPresent(...locator of element...)。例如:
$cell = "//table[@name='tableName']//tr[".$r."]/td[".$c."]";
$foundLink = $this->isElementPresent("xpath=".$cell."/a[.='".linktext."']");
$foundButton = $this->isElementPresent("xpath=".$cell."/button[@type='button']");
$foundImage = $this->isElementPresent("xpath=".$cell."/img[ends-with(@src='pretty-pony.gif')]");
Run Code Online (Sandbox Code Playgroud)
isElementPresent()如果有则返回true,false否则返回。
| 归档时间: |
|
| 查看次数: |
5569 次 |
| 最近记录: |