views:

737

answers:

3

Hey Ive tried looking for how to solve this for a couple hours and I keep coming up blank.

Im using Selenium IDE to try and make a few simple Automated tests (basically the test will access the site, create content and submit it, to ensure that it still works)

But there is a part of the site that is a javascript text box and i need to enter text into it.

However Selenium doesn't recognize any actions I make inside the text editing section of the box. It will recognize if I press something like BOLD or ITALICS. When I select BOLD it returns: click | //a[@id='mce_editor_1_bold']/img |

But like i said, it wont recognize when I select the text editing part of the box. I tried using xpath (and firebug) after some research online, but I cant seem to make that work.

Anybody have help or ideas to offer?

A: 

You can also use javascript to work with Selenium. So for example, if your rich text box has id="RichText" you can obtain the element via javascript and input your value there.

The code looks something like this:

| verifyEval | javascript{this.browserbot.getCurrentWindow().document.getElementById('RichText').value = 'Foo Bar'} ||

However, I've found that the syntax can vary for the this.browserbot portion. It will take a bit of work to get things going. You can also checkout this article from The Automated Tester which has information on what you're trying to do.

Also this question should help you out further: Selenium: How do I use javascript to clear a value from a form field?

Gavin Miller
A: 

I would recommend persevering with Firebug. Open the page that your testing and use Firebug's 'Inspect' feature to locate the text box in the HTML source. Then you should be able to find a way to locate the box using id, xpath, or css.

For example: If it has id='textBox' you can locate it using id=textbox. If it has class='jsTextBox' you can locate it using css=.jsTextBox

Otherwise you can use XPath - I'd recommend getting the XPath Checker extension so you can right click the text box and find out the XPath. You might want to play around with the result to make it a smarter XPath though.

Once you've found out the location you should be able to input data using the type or typeKeys commands. type changes the value, and typeKeys fires key up/down for each character - it's slower but sometimes needed depending on the application under test.

type | id=textBox | myValue

verifyValue | id=textBox | myValue

Hope this helps, Dave.

Dave Hunt
A: 

Guys,

I tried using both the above solutions and unfortunately, i was not successful with anyone of them.

The following code of line works fine if the id is that of a simple text box but with a rich text box, it does not work. Same is the case using the javaScript.

selenium.Type("//div[@id='edit-usertip-body-wrapper']/textarea[@id='edit-usertip-body']", "Adding up a new value for the Rich Text Box.");

Any solutions?

Kind regards,

shirwani