4

I'd like to do something like:

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

How to do that in phpunit-selenium?

1 Answer 1

6

You need to use execute() to execute javascript and set the attribute using setAttribute():

$this->execute(array(
    'script' => "document.getElementById('my_id').setAttribute('name', 'value');", 
    'args' => array()
));
Sign up to request clarification or add additional context in comments.

1 Comment

Note, the ->value() method still works for setting the value attribute. Getting was removed in selenium 2.43, but they left the underlying POST in the wire prototcol.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.