Monday, April 28, 2014

Another day, another Selenium gotcha or two

1. Entering text into rich text editors (iframes with content editable).

Basic:

$this->frame('frame-id');
$this->keys('the text');
$this->frame(null);

Works in Firefox.

In Chrome, you also need:

$this->frame('frame-id');
$this->one('body')->click();
$this->keys('the text');
$this->frame(null);

Note that because we're in the 'scope' of the iframe, $this->one('body') is the body element of the iframe.  Clicking on it gives it the focus so that the keys() get to the iframe.

Doesn't work in IE (10 on Win 7, at least).  Win 7 can't find the body element (although putting in an echo $this->source()) confirms it's finding the iframe OK.

Couldn't work this one out.  The only thing I could do with this is a browser sniff for IE, and if it is inject some javascript to set the value manually.  Because the text editor is empty, I can't click() on any other elements in the iframe.  Horribly hacky.


2. Auto correct

I was putting the text 'i have a comment' into a normal text editor.  Turns out IE autocorrects that to 'I have a comment' which means the test fails when it compares the strings after saving.



Grrr.....

No comments:

Post a Comment