如何使用phpunit-selenium设置元素属性


How to set element attribute using phpunit-selenium

我想做这样的事情:

// pseudocode
$this->byCssSelector('p')->setAttribute('attributename', 'attributevalue');

如何在氢硒中做到这一点?

你需要

使用 execute() 来执行 javascript 并使用 setAttribute() 设置属性:

$this->execute(array(
    'script' => "document.getElementById('my_id').setAttribute('name', 'value');", 
    'args' => array()
));