Translate

Saturday, July 30, 2016

Debugging Your Selenium IDE Tests

The most useful debugging tool is the the breakpoints that you can set in the Selenium IDE window. For those of you who do not know what a breakpoint is, let me explain. Breakpoints allow you to set a spot in the code, or this case the commands, for which the program pauses at that point and allows you to walk your way as far as you want to go. So when you're debugging Selenium IDE this is nice because you can see what the case is doing step by step.




Another tool I found useful when debugging anything dealing with variable, is the ‘echo’ command. The ‘echo’ command allows you to display what is in the variable. To use the command you put the variable like this ${variable} in the target. Now make sure you use the curly braces, when I first used this I thought those were normal parentheses.


Friday, July 29, 2016

Selenium IDE Workarounds

Last blog post I wrote about the fireEvent command and the basics with it. Today the topic is workarounds. One of the major workarounds I have found is with the fireEvent command. If the click or the mouseover or the mousedown commands are not working you can always use the fireEvent command.
One of the best things I have found to create workarounds is using logic. You can mimic almost anything you would like to do with combinations of other commands. For example, if you need to drag and drop something and the command is not working for some reason you can use the mousedown command with the mousemove or the mouseup commands or similarly if the those commands aren’t working, you can use the fireEvent command to mimic those commands.

Another way to workaround various issue is learning JavaScript. You can run snippets of JavaScript in IDE which allows you more variety in the possibility of actions



If you have any questions or comments please leave them below.

Thursday, July 28, 2016

Selenium IDE 'fireEvent' Command


One of the commands that I have found most helpful in running IDE scripts is the fireEvent(AndWait) command. This command can run any event that a specific object is supposed to do. For example, if you need your cursor to hover over something:


This screenshot actually has quite a few fireEvent commands, but we will just look at the mouseover. So the element here css=span.submenu-trigger has an event attached to that if you mouseover it triggers something. So by firing the event mouseover it fires that event.
Any event that is associated with the target, or element, you can fire with the fireEvent command.

I use this command mostly because of the nature of the website that I test, the normal commands like click don’t work.



If you have any questions or comments please leave them below.

Wednesday, July 27, 2016

Selenium IDE Add ons

Selenium IDE, like most other technical programs, has updates regularly. Because of this they have come up with 2 types of updates. One is the normal reinstall that has all of the updates on it. The other are the plugins. Now the Plugins are tricky because of the Selenium being open source there are other people besides selenium that writes these plugins. The plugins not done by Selenium you have to be careful with, but for the most part are good and add to the capabilities of Selenium IDE.
To add a plugin to IDE you add the plugin to Firefox. So the same way you added Selenium IDE you add other plugins for Selenium.
You can also remove plugins that you don’t need or don’t want



The best, or at least the most useful, add on is flowcontrol. It allows you to use looping and gotoif commands which are really helpful when trying to test edge cases.



If you have any questions or comments leave them below.

Tuesday, July 26, 2016

Creating Your First Test Suite In Selenium IDE

Once you have a test case or 2 you can save them as a Test Suite. The advantage of this is you can run a test suite which will in turn execute each of the test cases in the test suite. One thing I have found is that test cases in a test suite can act together to accomplish something. For example, I use a 3 test cases to get to a specific web page that is needed for the rest of my test cases, almost like building in the precondition of the test case.

In this screenshot you can see that underneath test case you have all of your test cases in a suite. A note on test suites is that you can add already built test cases to a specific test suite. So if you need to have a precondition met and you have already written a test case for it you can import, or ‘add’ it to the test suite. You can also add knew test cases and build in the existing test suite. You also have the ability to move around test cases, so that as you build them you can rearrange them.


If you have in questions or comments please leave them below.


Monday, July 25, 2016

Different Selenium IDE Internal Options

Along with having commands to create different test cases there are quite a few options and tools built in to Selenium IDE to help with these test cases. One of the most helpful is the speed
This bar helps determine how fast to run through all of the commands in a test case/suite or in other words how fast to run line to line. An example I have seen is if the website you are testing has a lot of javascript and you have to wait for things to load it might be better to run the test a slower so that the webpage has time to catch up to the commands.
Another Selenium IDE tool is that of the Play and the Pause buttons.
The first button here is to play a test suite, which basically means play all the test cases open. The next one is to play just the test case, then the pause is to pause the test case where it is at.
The next capability Selenium IDE has is to set breakpoints and step through them. To set breakpoints you right click on the line of code that you want to set the breakpoint and the right click menu has a ‘toggle breakpoint’ option.
Another option that is also available that is similar to breakpoint is the ‘Start Point’ which can be toggled in the same way as the breakpoints.
You can also insert new commands as well as copy and paste them. Something to note is that if you copy and paste them they paste above the line that is selected.

If you have any questions or comments please leave them below.

Saturday, July 23, 2016

The Way to Locate Targets In Selenium IDE

This is one of the most difficult things if you have even a semi-complicated website. There are multiple ways to locate targets. One of the easiest, is to use the select next to the target input box in selenium then all you have to do is click on the element that you wish to target.
The way it works is that there are multiple ways in which you can ‘target’ a html element. One of the easiest and frankly the best way is to make sure to assign a unique id with each element that is on your webpage. This means that in the target field all you have to put is id=sampleIdCall.


Just to note that the id is of the html element.


Another way is through CSS. This allows you to check all sorts of things. I’ll give a few examples.  css=span:contains("New Document");This checks the document for an element span with text containing “New Document”. Another is css=div.save-status searches for a element div with the class name save-status. These are just 2 examples of css and there are plenty more that I did not specify that are just discovered as you go on.


Another way to identify targets is through something called xPath and is literally the html path to that specific element. It does have a couple different syntaxes. One is to write out every element on the path to the one that is your target, this can be long and a little unnecessary for 99% on the time. That 99% of the time you are using xPath you can do whats call a shortcut. For example, xpath=(//input[@id='rename-document-input'])[2]. Now this is a input box that has a id that may match another element’s Id therefore to clarify we use the [2] to indicate that it is the 2 input box with that Id.
I could probably write a couple pages just on locators but this should suffice for now. Just to note that this is not all inclusive there are many things that I have used that I did not put as examples and many things which can be used which I have never used.


More References:



If you have any questions or comments leave them below.

Friday, July 22, 2016

The Selenium IDE ‘...AndWait’ or ‘waitFor…’ or ‘pause’commands

Now these are not commands within themselves but more to increase the robustness of your test. For example, if your test is set to the fastest speed on IDE and you have to wait for a link to process or for a webpage to load you can call either clickAndWait which will wait till the event that you triggered, when you clicked on some element, or you can call, in this case, waitForPageToLoad which will wait till the html elements load on the webpage.




You’ll notice that each of these commands has a number in the value field. This is to set the timeout value, meaning how long is the maximum wait time.
I have found that using the ‘pause’ command in replacement of the wait can be helpful. Just a word of caution is that it is specific timing so that you cannot make it relative like the wait command but it can be a way to make your code run smoother. Also to note is that the amount of time you want to pause goes in the target not the value.



If you have any question or comments please leave them below.

Thursday, July 21, 2016

The Selenium IDE ‘click’ and ‘clickAt’ command

The click command is very useful when trying to simulate clicking on html elements. To use it write click in the Command line then select a target (we will talk about targets later on) to which you will be clicking on.
Now one nice thing about IDE is that it gives you a reference for each command inputted so that you can know what the parameters should be or even how many parameters there are. One thing that I have run into with the click command is when the website has a to of javascript, this is when you get creative and figure out that there is another command to help you with “clicking” on a target. We will talk about this command later on, because it is a more advanced command to deal with.
The other command, ‘clickAt’ is used to click on a location relative to the target. For example:

So the target is a locator(html element) then the value are the x,y coordinates. This command I have not found a particularly use for yet but I can see where it might be useful if you need to click on a specific spot on an element, but other than that I can’t see a big use for this over just the plain old ‘click’ command.




If you have any questions or comments please leave them in the comment section.

Wednesday, July 20, 2016

The Selenium IDE 'open' Command

After setting the base URL you can use it throughout your commands/code. The next step is to start writing the commands/code. Let us start with a simple command “open.” This command opens the url that is in the target area for example.


If you put “/” in the target it uses the base url. For example the base url is ‘www.google.com’ if you use the open command with “/” in the target it opens www.google.com.



With the “/” shortcut you do not have to write out the full url just the part after the base url that you set. If you want to open a different url other than the base url you must write out the whole thing.


If you have any questions or comments please leave them in the comment section.

Tuesday, July 19, 2016

My First Selenium IDE Project

As I was searching the web I realized that there was little in the ways of Selenium IDE tutorials and examples. As I go through this please note that this is not all inclusive and i am definitely human. I will try my best not to have mistakes but because of the fact that Selenium does update, no promises.
Let me begin with a little bit of background on Selenium IDE. It is a Firefox Plugin used for automating web based processes. For example, if you are testing a web site to make sure all the links work and you have to do this a couple of times a week. You could manually go into this website and manually click on each link or you could write a simple command based automation to do it for you.


Download Firefox
Go to this link to download
Download Selenium IDE
Go to this link to get the add-on for Firefox
Opening IDE
To open Selenium IDE Firefox must be open. There is a little icon that appears at the top left of the browser.
Create Test Case
When you open Selenium IDE it automatically opens a brand new test case. What you need to do is rename the test case to something that will draw attention to what the test case is supposed to test. You can rename the test case by right clicking on the test case and select Properties. You can then modify the lower line of the dialogue box that appears, this will modify the name but will not save the test case. You have to separately save the test case.

After the test case is named it is time to set the Base URL, this is the website that you will be testing.

If you have any questions or comments please leave them in the comment section.