RTE and selenium -uploading image.

I have been spending some quite times trying to upload an image using the YUI RTE. The problems with the upload, is that when the upload button is clicked it calls the native system file uploader (in my case linux) . And this makes selenium access limited. and unapproachable.

I had couple of issues with the RTE which was solved with more of  “google.com” and “meet the dead end-trace back and use another route” method 🙂

Problem: clicking on the upload button would not trigger the file upload overlay.

Solution: Instead of using the click method use the mousedown.

Problem: Inconsistency with speed.

Soution: Not too happy with this, but adjusting the setspeed to slower resolved the problem- this can be problematic when you are trying to figur eout how to run the script on environments that have varied perfomance, not to forget the VM‘s and OS‘s they will be run on.

Problem: How does one pick the file using th enative file selector menu if selenum does not recognize it?

Solution: You can’t. either try and mess with autoit (for IE) or directly type in your file path.

Here is the code: I have again used http://shine.yahoo.com. Please run the test after logging in. I ran it via the IDE so I could control speed using the little bar on the top left. When it comes to running it on the RC, I will need to find the speed it is optimal to run at. Enjoy. As always feel free to comment/email me if you have any suggestions or if you would like to share any nifty tricks.

package com.example.tests;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.<a class="zem_slink" title="Test cricket" rel="wikipedia" href="http://en.wikipedia.org/wiki/Test_cricket">Test</a>;
import java.util.regex.Pattern;

public class test extends SeleneseTestCase {
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.yahoo.com/");

public void testTest() throws Exception {
selenium.mouseDown("xpath=//*[@id=\"yui-gen8\"][@title=\"Image Options\"]");
selenium.type("xpath=//input[@id=\"insertimage_upload\"]", "<em><strong><enteryourimagefilepathere></strong></em>");
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (selenium.isElementPresent("xpath=/html/body/div/div[2]/div/form/div/div[2]/p")) break; } catch (Exception e) {}


public void tearDown() throws Exception {


One thought on “RTE and selenium -uploading image.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s