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

Bor*_*ard 4 php selenium phpunit selenium-webdriver

我想做点什么:

// pseudocode
$this->byCssSelector('p')->setAttribute('attributename', 'attributevalue');
Run Code Online (Sandbox Code Playgroud)

如何在phpunit-selenium中做到这一点

ale*_*cxe 6

你需要用来execute()执行javascript并使用setAttribute()以下方法设置属性:

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