Mikhail reminded me of the selenium Contributed User-Extensions at

http://wiki.seleniumhq.org/display/SEL/Contributed+User-Extensions

Thanks.

On Oct 21, 9:18 pm, [EMAIL PROTECTED] wrote:
> As for how to add a new method to Tellurium, I give an example here on
> how to do that. (We could make Tellurium configurable to new methods,
> but user rarely needs to define custom methods, we defer this
> implementation until there are requests of this feature from users)
>
> Take the typeRepeated method as an example, (Assume you have modified
> Selenium core script and added the typeRepeated method)
>
> First, open up the org.tellurium.connector.CustomSelenium class and
> add the following method in,
>
>        public void typeRepeated(String locator, String text) {
>
>          commandProcessor.doCommand("typeRepeated", new String[]
> {locator, text});
>
>        }
>
> Then, In the org.tellurium.dsl.BaseDslContext class add the following
> method to define a new DSL
>
>     def typeRepeated(String uid, String input){
>         WorkflowContext context = WorkflowContext.getDefaultContext()
>         ui.walkTo(context, uid)?.typeRepeated(input){ loc, String[]
> events ->
>             String locator = locatorMapping(context, loc)
>             eventHandler.typeRepeated(locator, events)
>         }
>     }
>
> where the walkTo method parses the uid such as
> "google_start_page.inputbox" to find the given UI object "inputbox".
> The closure
>
> {loc, String[] events ->
>             String locator = locatorMapping(context, loc)
>             eventHandler.typeRepeated(locator, events)
>
> }
>
> just generates the runtime locator and then call the eventhandler for
> the method "typeRepeated".
> If the custom method is to access data, you should pass the method to
> the accessor instead of
> the eventhandler. For details, consult the following example
>
>     boolean isVisible(String uid){
>          WorkflowContext context = WorkflowContext.getDefaultContext()
>          def obj = ui.walkTo(context, uid)
>          if(obj != null){
>              return obj.isVisible(){ loc ->
>                 String locator = locatorMapping(context, loc)
>                 accessor.isVisible(locator)
>              }
>          }
>
>          return false
>     }
>
> Third, you need to add a method to the
> org.tellurium.event.EventHandler class in the case of "typeRepeated"
> as follows,
>
>     def typeRepeated(String locator, String input, String[] events) {
>         String[] defaultEvents = null
>         if(extraEvent)
>            defaultEvents = ["focus", "mouseOver", "mouseOut", "blur"]
>
>         processEvents(locator, events, defaultEvents){
>            dispatcher.typeRepeated(locator, input)
>         }
>     }
>
> For org.tellurium.access.Accessor, it is simpler and just passes the
> method to the dispatcher as follows,
>
>     def boolean isVisible(String locator){
>
>         return dispatcher.isVisible(locator)
>     }
>
> Then you need to add the new method to your UI object, for example,
>
> class InputBox extends UiObject{
>     ...
>     def typeRepeated(String input, Closure c){
>         c(locator, respondToEvents)
>     }
>     ...
>
> }
>
> After that, you are done. In your test file, you can use the
> typeRepeated now
>
> typeRepeated "google_start_page.inputbox", "tellurium"
>
> It is a bit complicated at the first sight, but not really after you
> read the code since
> the code looks like boilerplate code. Also you should understand the
> call flow in
> Tellurium.
>
>            DslContext
>                     |
>            UI Object
>                     |
>            EventHandler / Accessor
>                     |
>            Dispatcher
>                    |
>            SeleniumClient
>                    |
>            SeleniumConnector
>                    |
>            CustomSelenium
>                    |
> ----------------------------------------
>                    |
>            Selenium RC
>                    |
>            Selenium Server
>                    |
>             Selenium Core
>
> Let me know if you have any further questions.
>
> Thanks,
>
> Jian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tellurium-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/tellurium-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to