Tuesday, February 16, 2010

Selenium AutoIT

Hello, welcome to my first blog.

As the blog title says, I have started working on creating a selenium autoit driver.

Currently, I have created couple of files which can drive the selenese commands and execute the test case.

I did not find any upload file feature so hosting the files on another server. :(


Download from here

After unzipping the rar file, you will find the below files:

  • Selenium.au3
  • SupportFunctions.au3
  • GoogleSearch.au3 
  • options.ini 
more details of each file:
Selenium.au3 - This file contains the functions for starting selenium server, stopping the session and executing the selenese commands.

SupportFunctions.au3 - This file contains the functions for report and etc..

options.ini - This contains the different configuration to run/start the server.

GoogleSearch.au3 - This is the actual script file which contains the actions to be performed on the browser.
  • Each test case is written as a function. Example shown below.
========================================
Func BasicSearchInGoogle()
_TestCaseBegin("BasicSearchInGoogle")
        _Execute("open", "/")
_Execute("windowMaximize")
_Execute("type", "q", "AutoIt")
_Execute("clickAndWait", "btnG")
$test = _Execute("assertTextPresent", "AutoIt")
If ($test) Then
_TestPass()
Else
_TestFail()
EndIf
_TestCaseEnd()
EndFunc   ;==>BasicSearchInGoogle
========================================

  • There are some special functions to be called and below are such functions:
  1. _TestCaseBegin(STRING sTestCaseName) - This function should be called at the start of the test case with test case name. This is required to maintain the results files and counters.
  2. _TestCaseEnd() - To handle any cases that we like to do after a test case is executed.
  3. _ScriptStart() - This is required to start the selenium server and to initialize all the global variables.
  4. _ScriptEnd() - This is to handle any action after a script is completed. Ex: sending a mail with results.
  5. _TestPass() - Call this function if you know that your test case is passed.
  6. _TestFail() - Call this function if you know that your test case is failed.
Please let me know if you need further details.

17 comments:

  1. Hi!
    Thx a lot 4 thess useful scripts.
    Maybe you have an idea how I can pass URLs containing an ampersand?

    ReplyDelete
  2. You should try using URL encode format to send these special characters.

    Ex: _Execute("open", "/something%26name=joy")

    The above statement would open default page with following URL /something&name=joy

    Thanks,
    Bhima

    ReplyDelete
  3. how to upload file in selenium using Autoit

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. The simple solution is by using default selenese command as below:
    _Execute(albumPic,"C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\Sunset.jpg");
    Where albumPic is the object identifier of the normal html control of type 'file'.

    ReplyDelete
  6. If the HTML object is not the type of 'file', then you need to use AutoIt window identification tool to identify which buttons, text boxes you want to use and take appropriate actions on them. Let me know what exactly your requirement is.

    ReplyDelete
  7. iam using java client and i tried attach ,but in IE it is not working .

    tried robot too ,but no solution!?!

    ReplyDelete
  8. Sasi, can you post what is the HTML tag of the element you are trying to upload file?

    ReplyDelete
  9. file is not getting downloaded...please post it in some other website

    ReplyDelete
  10. The file can be downloaded @ http://www.autoitscript.com/forum/index.php?showtopic=110295

    ReplyDelete
  11. Hi Bhima,
    is this tool can help in handling JS alerts?

    ReplyDelete
  12. Does this support Selenium Grid? Would be nice enhancement if not.

    ReplyDelete
  13. Any plans for Selenium 2/WebDriver support? Be nice to look into.

    ReplyDelete
  14. @Sobeers : Yes this can handle JS alerts. All you need to do is record the buttons using AutoIt WindowInfo tool and take action.

    @man9aroo : Yes, to my knowledge this works on slenium grid. Please give a try and let me know.
    I do not have any plans to support WebDriver now.

    ReplyDelete
  15. sorry, I would test this, but the file is not available...

    Can you upload the file again, please?

    Tx

    Henri
    henriclaessens@gmail.com

    ReplyDelete
    Replies
    1. Sorry for the late replay.. please download the file from this location

      http://www.autoitscript.com/forum/index.php?app=core&module=attach&section=attach&attach_id=29698

      Delete
  16. Hi Bhima,

    Thanks a lot for this useful post.
    Can we call css components from this , if yes the an example can be of a great help

    ReplyDelete