GUI Map

This extension allows to utilize in the selenium concept of GUI map that is widely used in the 'commercial' tools for test automation.

Why would you want to use it?

1. many control ids in you application-under-test are 'autogenerated' and look like _ctl0_page_header__page_header__tbp_window_items_list__ctl0__ctl1____toolbar_print_view, but you prefer to see something more meaningful, like uimap=customers.ee.view.lnk_print_view.

2. control ids change occasionally and you want to have a single place to modify changed id.

How to add it to selenium:

1. create file 'gui_map.js' in the selenium's folder with content

gui_map.js
 
   var gui_map = {};

2. include it in the 'TestRunner.html' like:

TestRunner.html
   <script language="JavaScript" type="text/javascript" src="gui_map.js"></script>

3. add following code into the 'users-extensions.js':

users-extensions.js
PageBot.prototype.locateElementByUimap = function(identifier, inDocument)
    {
    var element_id = eval("gui_map." + identifier);
    if( !element_id ) 
        { throw "no such entry in UI Map: " + identifier; }

    var res = this.findElement( element_id, inDocument);
    return res;
    }

Example:

Sample GUI Map (gui_map.js):
gui_map.js
 
  var gui_map = {

    main:   { lnk_logout:             "link=Logout"
            , lnk_customer_section:   "link=Customers"
            , lnk_jobs_section:       "link=Jobs"
            , lnk_my_items_section:   "link=My Items"
            
            , quicksearch: { p_topic: "_ctl0:_ctl3:topics_"
                           , keyword: "_ctl0:_ctl3:keyword_"
                           , btn_go:  "_ctl0:_ctl3:go_"
                           }
            , recents: { lnk_clear:        "link=[clear]"
                       , lnk_fn_link_id:   function( x ) { return "_ctl0__ctl7_rpt_recents__ctl" + (x + 1) + "__ctl0_v_jump" }
                       }
            }
            
    // etc.......................            
    };
Sample selenium's code:
clickAndWait uimap=main.lnk_jobs_section
verifyElementNotPresent uimap=main.recents.lnk_fn_link_id(0)

Questions:

Q: can this be used together with the Selenium Recorder? (I've never used the recorder before.) Most people use GUI maps together with automated recording tools to ensure that the recorder is capturing the "relevant" information about the test objects.

A: Never used the recorder, haven't seen the code; so I cannot estimate how hard it is to add support of gui map there.

File: 

AttachmentSize
Package icon selenium-0.7.zip361.62 KB
Plain text icon selenium-browserbot.js.txt31.48 KB

Type: 

User-Extension