Thursday, March 28, 2013

Selenium IDE : Need Date or Time


Selenium IDE

Get the Current Time, Date, Month and Year



Current Time -

 javascript{(new Date().getHours()+" : " + new Date().getMinutes() + " : " + new Date().getSeconds())}


Current year - 

javascript{(new Date()).getFullYear()}


Current Month - 

javascript{(new Date().getMonth()) + 1}


Current date - 

javascript{(new Date().getDate().toString())}

Friday, March 15, 2013

Link Finder and Checker (python)


Summary:  This is a python script to check all the links on a single webpage to verify that all links are valid and not 404's.

Download: linkFindersmsV2.py

Make sure the latest python 2.7 is installed on your machine if not get it here and all paths are set correctly on your machine.

Now open a command prompt
navigate to where the linkfindersms.py is located in you directory







now run linkfindersms.py










It will prompt you for the URL, Enter the URL in this format: http://www.google.com
then hit enter.






If something other than a 200 response comes back you can see which links that cause the error by typing the code from the array.
In this example there is a 200 code and a 403 code.
type 403 to see what links on the page have the 403 code.



If your on a mac you can use the curl method to see what the response was that give the 0 error
Then type 'quit' to exit


leave comments of any other ideas you may have or errors in the code.






Like GIt but your team likes Mercurial.....do what you want!


Like git but your team likes mercurial.....do what you want!

How to tell if it’s HTML5



How to tell if it’s HTML5

Wednesday, September 5, 2012

Putting a head on Selenium: Display on a remote sccreen (windows)





     The advantages of having a headless system are ideal for any development cycle.  It speeds up testing times and allow the test to be run on the server.  These along with many other advantages are great but only IF you can get them to run.  One of the biggest problems and time consuming steps of using a headless system is trying to debug your test. Ideally, you run these test on you local machine and then you send them to a server repository where the will run.  As anyone who has even dabbled a little in the automation world knows things do not always give the same results on different systems and set-ups. Things can then get even more diffcult when the system is headless and you cant actually SEE the issue.

After much search i could not find any straight answer to how to exactly to export this display to my windows machine from our linux servers. Its really quite simiple and can be done in a few steps.

In order to display a headless selenium test on Windows Machine from a linux server you must first be able to have an X server running on you Windows machine. I used Xming as it is the easiest with almost no setup.

You need to download Xming from here:





When the installer finishes run the Xming server. Now you need to download Putty if you dont already have it you can get it here:


Download Putty.exe


http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html


Now that you have installed Putty run the executable.  In the left hand catagory listing for the settings click on the X11 tab and enable X11 forwarding!.







Type in you Host name or IP and connect.

Type firefox in the command line of you putty instance (ths assumes you have firefox on your system)

This should pop the firefoxbrowser!

Now that you can get the firefox profile to show on you machine you can run selenium and debug on the fly with the command:

 java -jar (PATH-TO)/selenium-server.jar -trustAllSSLCertificates -htmlSuite $BROWSER $URL  (PATH-TO)/$SUITE  (PATH-TO)/$LOG








Wednesday, August 29, 2012

Selenium IDE


 

Selenium IDE

Selenium IDE is a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.
If not the newest version check here for most recent:  http://seleniumhq.org/download/

How to use video: 



Commonly Used Selenium Commands

To conclude our introduction of Selenium, we’ll show you a few typical Selenium commands. These are probably the most commonly used commands for building tests.

open  opens a page using a URL.
click/clickAndWait  performs a click operation, and optionally waits for a new page to load.
verifyTitle/assertTitle  verifies an expected page title.
verifyTextPresent  verifies expected text is somewhere on the page.
verifyElementPresent  verifies an expected UI element, as defined by its HTML tag, is present on the page.
verifyText  verifies expected text and its corresponding HTML tag are present on the page.
verifyTable  verifies a table’s expected contents.
waitForPageToLoad  pauses execution until an expected new page loads. Called automatically when clickAndWait is used.
waitForElementPresent  pauses execution until an expected UI element, as defined by its HTML tag, is present on the page.
SendKey for typing keys into inputs (also type and typekeys work)

Favorite add-on's to IDE

Flow Control:  https://addons.mozilla.org/en-US/firefox/addon/flow-control/

Examples of implemented commands:
gotolabel / label
Unconditional jump
gotolabeltestlabel1
........
labeltestlabel1
gotolabel parameters:
  1. a label to jump to
gotoIf / label
Conditional jump
gotoIf/corrrect caption/i.test( storedVars.pagetext )testlabel1
........
labeltestlabel1
gotoIf parameters:
  1. javascript expression
  2. label to jump to if javascript expression evaluated as true
(obsolete) assertNoFailureOnNextAndGoto / assertNoErrorOnNextAndGoto / label
this command is dropped in extension for Selenium Core v.0.8+
Jump if following command passed
assertNoFailureOnNextAndGototestlabel1
verifyTextelementcorrect page
open./pageneeded.html
labeltestlabel1
while/endWhile
Cycle
store0loop2
whilestoredVars.loop2 < 2
storejavascript{storedVars.loop2++}
endWhile

while parameters:
  1. javascript expression.

Screenshot on Fail: https://addons.mozilla.org/en-US/firefox/addon/screenshot-on-fail-selenium/

Capturing a screen shot on error or failure is a useful ability that has been available to Selenium users via programming languages. Selenium IDE users did not have an easy option so far. My Screenshot on Fail plugin for Selenium IDE makes this available as a single click feature. When the screen shot on fail plugin is enabled, this plugin will automatically grab a screen shot of the complete web page at the point of test failure. The screen shots are captured for the entire web page and give you an opportunity to review the exact state of the web page when the failures occurred. I have uploaded it to the Mozilla Addons website, but the approval process to make it public usually takes a while. The good news is that you can grab it right now from the addons page.
Once you install the plugin, a Screenshot on Fail tool button will be available on the Selenium IDE toolbar. See the screen shot.
Mini user guide for the plugin:
View failure reports
  • Click on the Screenshot on Fail tool button to turn on capturing screen shots on failure.
  • Run your test case or test suite to capture page coverage.
  • Click on the small arrow next to the Screenshot on Fail icon and then click View failure report menu item to open the failure report.
  • This should open all the failure reports or the latest one if you have just executed a test case or test suite.
  • Click on the Screenshot on Fail tool button again to turn off page coverage.

Page Coverage: https://addons.mozilla.org/en-US/firefox/addon/page-coverage-selenium-ide/

Page Coverage plugin for Selenium IDE that get you the page coverage of the Selenium IDE based tests. I have uploaded it to the Mozilla Addons website, but the approval process to make it public usually takes a while. The good news is that you can grab it right now from the addons page.
Once you install the plugin, a Page coverage tool button will be available on the Selenium IDE toolbar. See the screen shot.

Mini user guide for the plugin

  • Click on the Page Coverage tool button to turn on page coverage.
  • Run your test case or test suite to capture page coverage.


    View Page Coverage Reports
  • Click on the small arrow next to the Page coverage icon and then click View Page Coverage menu item to open the page coverage reports.
  • This should open the all page coverage reports or the latest one if you have just executed a test case or test suite.
  • Click on the Page Coverage tool button again to turn off page coverage.

Sample Page Coverage Reports

These reports show the elements that were used in the test.
  
Sample Page Coverage Reports

Known Issues / Notes

  • The last link or button clicked that triggers a page load will not be captured in the page coverage.
  • Using page coverage with this plugin is destructive, i.e. it changes the web page to mark the elements used by the tests . This may sometimes affect your tests. So always run your tests without page coverage to verify the correct results.
  • You will see “Error: Image corrupt or truncated” in the error log almost every time a screen shot is taken. The screen shot is still saved correctly.
  • If you turn on both highlight elements and page coverage at the same time, page coverage will take precedence. You can have them both installed without problems.
To use this plugin, you will need to install Selenium IDE extension of at least version 1.0.4 first. Only in English for now.