Selenium: How do I assert that a certain element is present in a certain cell of a certain table?

前端 未结 2 460
萌比男神i
萌比男神i 2021-01-18 07:37

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

2条回答
  •  旧巷少年郎
    2021-01-18 08:22

    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.

提交回复
热议问题