Thursday, February 27, 2014

Window's InputSimulator Radio Button Check

Just another day another learning experience. I was asked by my employer to write a selenium script to import about 2000 data entries into a web portal. This was the first selenium script I have wrote and with help from a colleague that works with selenium daily I was able to accomplish this task.

First the Dependencies:

WindowsInput
Selenium


WindowsInput is a dll you can paste and reference in your bin a short google search should yield results for this  so I won't go to any detail unless someone requests it then I'll do a follow up post. Selenium and be installed via the Nuget Manager within Visual Studio which is a blessing from heaven no more searching around the web for what you need.

So here is my little method which is more just to display some of the options that I used to write my script. The comments are self explanatory this is a very basic implementation. You will notice the ability to navigate to a url. My experience included adding logic for basic auth before I was able to put any input in the forms.


So what I wanted to throw out here in this blog post was the simple fact that I hunted around the web for  about 40 min trying to find how to check that lame radio button on the import form. I could get the focus on the radio button but I was unaware that there was any keyboard stroke that could fill that puppy in. Where the limitations are that I could not use the mouse buttons I had to find and alternate way of doing this. I finally ran across this page from Mozilla which is awesome because I'm writing this script in Firefox there are ways of using other browsers as well. 

Mozilla Forum


So there I learned that you could turn a radio button on or off by selected the spacebar. So as you can see in my code the last simulation is the space which selects the radio button, the rest of my data fills and the submit button selected and all is right in the world. I just thought I could maybe save someone else the same 40 minutes our time is precious. Also maybe this is just common knowledge let me know if I'm super lame and I was living in ignorance. Thanks. Remember to code like Vikings.