I have a table on my page which is supposed to contain a certain element. I can identify the table by its name (it has a unique name), and I can also identify the element ea
Sounds like you want isElementPresent(...locator of element...)
. For example:
$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')]");
isElementPresent()
returns true
if so, false
if not.
You could try Selenium's getXpathCount
$this->("xpath=//table[@name='tableName']//tr[".$r."]//td[".$c."]//TAG");
This will return the number of matches the xpath gets. in your case, zero would mean a fail.