phpunit-selenium
phpunit-selenium copied to clipboard
Set text() function
Hi There,
I need a function to set html / text inside the div.. as I know phpunit-selenium only has the function for getting the html / text inside the div, by using $this->byId('xxx')->text();
Now my question.. is possible set the html/text inside the div id by using that code like this :
$this->byId('xxx')->text('new value');
Actually I tried this but it Im getting error : invalid json or something..is there any proper function for it?
Thank you
Hi, "text" function is meant to read values. If you want to send a secuence of keys you can use $this->byId('xxx')->value('new value');
You can find a comprehensive list of commands at: https://code.google.com/p/selenium/wiki/JsonWireProtocol
Thank you.. I thought the value () function wont work for the div :)..
Wow! You're right, I think value function is only supposed to work on input fields. Let me know your discovers!
If I interpret the vision of Selenium 2 correctly, you can only do what a user could (for example invisible elements are not even accessible). So can a user set the text of a div in your page (without Firebug or other plugins)? Usually no, so that's why Selenium does not support value() for generic divs.
However, I think (without testing it) that if the div is contenteditable then you should be able to focus on it (perhaps $el->click()) and then use $this->keys('abc') to send the keystrokes.
If it's not contenteditable, then you could send some javascript directly; but I'd seriously wonder why you'd want to do that, tbh.
well Matt, I havent tried use keys() function.. but thank you for your input.. :)
in my application, i need to edit the text value (innerHTML), but now the feature already changed we are not using element text anymore, we are using standard input instead.. I found which use contenteditable is slower than instead input instead.