Selenium IDE typeKeys missing dot, period, or decimal 1

I discovered a bug in the Selenium IDE today where I needed to use the typeKeys command and the value included a period. The period would be stripped out for some reason. The solution is to break the command into two separate commands. First, use the “type” command and include the period or dot in the value (nick@gmail.). Then, create another command on the same input and use the “typeKeys” command to add the rest of the value (com).

Selenium Testrunner variables don’t work 6

I have some tests where I store variables and they saved and work fine in the regular test build window. Specifically, I can store a variable in one test, then run another test afterwards and reference the variable for use. However, when the tests are run in Selenium’s Testrunner, the variables are inaccessible if not created in the current test. They do not save across tests in the Testrunner. Please comment if you have a solution. For now, I’ll be running all our tests from the build window.

Must know commands for Selenium IDE 47

Over the past couple weeks I’ve written 70 test cases with Selenium IDE.  Since completing the project, I’ve gone back to the first 20 or so and improved them with new commands that I learned and are more reliable in certain situations. In general, when working with elements on a page, the “target” should point to the ID of the element you’re working with and the value is many times optional.  In general, referencing the ID of an element instead of using xPath will save you work in the future when your page structure changes in the future.

Below are the commands I found most useful for testing our web application, which uses many forms and ajax.

echo – I always echo out some text that will help me identify the current test case.  When you’re looking through the logs after running your whole suite of tests, the logs all run together with no break.  You can’t tell which test case had an error unless you echo something like —————- my test case name ————

open – tells the browser to open a specific page.  This is useful if you don’t want the test to navigate to a page and instead just want it to go straight there.  This can be a relative path so you can use it on both a testing and live environment.

Type and TypeKeys – type will place text in an input.  Typekeys will actually mimic entering one key at a time so any onkeyup() functionality you might have going on will work.  We have autocomplete search boxes that required TypeKeys.

verifyTextPresent – Verifies that text appears on the page.  It can be dynamic text that was loaded with ajax.  If it’s on the page in the active window at the time this command is called, it’ll find it.

verifyValue – Verifies the value of an input field.  Provide the id of the input as the target and the value is the text you’re expecting.

click – tell the test to click something on the page.  The target can be referenced with the element ID or xPath as with the other commands.

clickAndWait – Useful for form submissions.  Many times when you’re in record mode and click a submit button, selenium will only record a “click” command.  This will break your test commands following the form submission where you verify the presence of a success message or form values because the next page hasn’t loaded yet.  The “wait” portion will wait to continue the testing when the next page has fully loaded.

select – select an option in a select box by providing the id of the select box and the option value.

pause – Tell the test to pause for a while.  Enter a target of 3000 for 3 seconds.  I started using this command frequently at first, especially when testing ajax.  However, as I went on I found better alternatives since a TCP/IP connection isn’t always reliable and doesn’t get returned on time, every time.

waitForVisible – This command tells the test to wait until an element, often returned by ajax, is visible before continuing.

storeAttribute – Selenium IDE can store variables and allows you to reference them in the same test case or another test case.  The target of this command should point to the text or value to store.  You’ll most likely use xPath for this one.  This example will reference the value of an input field named newTicketId //input[@name=’newTicketId’]@value .  The value of the storeAttribute command will be the variable name to save it as.  Reference the variable in another command with prototype syntax like ${variableName}.

Selenium IDE and TinyMCE 35

I created a test case for creating a support ticket.  Our support ticket interface has multiple tinymce editors present for the various ticket description and action update fields.  I had a difficult time find a solution that would make Selenium IDE type text into one of these tinymce editors, but I found one that worked using the dom.  Use command “type” and target should be “dom=document.getElementById(‘id_of_the_tinymce_frame’).contentDocument.body” and the value can be any text you want entered into the tinymce editor.

Note – if you copy and paste the dom code above, you may have to redo the single quotes around the id after you paste it somewhere else.  I did this and the character changed and threw me off for a bit.