我正在使用 PHP Selenium Webdriver 包装器Facebook https://github.com/facebook/php-webdriver。任何人都可以给我一个如何单击或从选择下拉菜单中选择选项的示例吗?
我已经尝试过这个:
$test = $driver->findElement( WebDriverBy::id('drop1').WebDriverBy::cssSelector("option[value='11']"));
$test->click();
但它出错了:
Message: WebDriverBy 类的对象无法转换为字符串
它应该是
$test = $driver->findElement( WebDriverBy::id('drop1') )
->findElement( WebDriverBy::cssSelector("option[value='11']") )
->click();
如果您正在使用“选择”标签,请使用WebDriverSelect
反而。
$select = new WebDriverSelect($driver->findElement(WebDriverBy::id('drop1')));
$select->selectByValue('11');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)