Happy new year to everyone.

I want to share a simple extension.
It 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____toolba
r_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.

To use the gui map you need to:

1. create file 'gui_map.js' in the selenium's folder with content
   ----------------
   var gui_map = {};
   ----------------

2. include it in the TestRunner.html like:
   <script language="JavaScript" type="text/javascript"
src="gui_map.js"></script>

3. add following code into the users-extensions.js:
   ----------------------
   PageBot.prototype.locateElementByUimap = function(identifier, inDocument)
    {
    return this.findElement( eval("gui_map." + identifier), inDocument)
    }
    ---------------------

Now you can modify your GUI map in the gui_map.js as e.g.:
  ------------------------------------------
  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.......................
    };
  ------------------------------------------

After you created GUI Map for your application, you can use it like:

clickAndWait             |  uimap=main.lnk_jobs_section
verifyElementNotPresent  |  uimap=main.recents.lnk_fn_link_id(0)


Hope you'll find it useful.

------------------------------
Andrey Yegorov
MetaCommunications Engineering


_______________________________________________
Selenium-users mailing list
Selenium-users@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-users

Reply via email to