Mink/Goutte How to check checkbox without attribute in Goutte?

冷暖自知 提交于 2019-11-29 17:24:30

Try to use click and also add Exception in case that the element is not found.

Example: If the element is not found, the find method will return null and you will try to click on null, this will throw a fatal exception and your suite will stop.

if you add an exception only the current scenario will fail and the suite will continue to execute.

public function iClick($selector, $locator){
    $node = $this->getSession()->getPage()->find($selector, $locator);

    if($node === null){
        throw new Exception("Element $locator not found!");
    }else{
        $node->click();
    }
}

If the element is type checkbox and you want to do a check, no matter if is checked or not, you can create a method that uses check() instead of click()

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!