I thought about it a bit. Two ways come to my mind.
The first one is to define an abstract UI object with variables such as
ui.Table(uid: "keyValue", clocator: [class: "keyValueTable"]){
TextBox(uid: "{row: any, column: 1} as p1, var key", clocator: [text:
"key"], self: "true")
TextBox(uid: "{row: any, column: 2} as p2, var value", clocator:
[text: "value"], self: "true")
}
In the above UI module, I defined two variables: key and value.
The abstract object could not be used directly and it must be instantiated
with values binding
to the variables. I need to come up with a mechanism to instantiate multiple
instances based on
the abstract objects. For example,
spawn "keyValue.p1", "KA", [key: "AAA"]
spawn "keyValue.p2", "V1", [key: "111"]
spawn "keyValue.p1", "KB", [key: "BBB"]
spawn "keyValue.p2", "V2", [key: "222"]
where "KA", "KB", "V1", and "V2" are new IDs. The new instances will be
inserted into the Table "keyValue".
The key point here is to programmatically change the runtime UI module.
After that, you can use
"keyValue.KA", "keyValue.V1", "keyValue.KB", and "keyValue.V2" to reference
them.
The second option is to define a find() method for a UI object,
find(Map attributes)
In this way, the above method will first locate the UI object (i.e., the
table "keyValue" itself in the above example), then
find its children or descendants by the given attributes. Probably, we can
also assign a temporal uid for each found
element like what getUiByTag does so that you can use the temporal uid to
reference the found UI element.
This changes will not make its way into 0.7.0 RC2. I will see if I can
squeeze them in before 0.7.0 final release. If not, should
be included in 0.8.0.
Any suggestions and comments are welcome.
Thanks,
Jian
On Wed, Apr 7, 2010 at 11:19 PM, John <[email protected]> wrote:
> Hi Graham,
>
> Great questions.
>
> Tellurium does support direct Selenium calls with the following
> method,
>
> def customDirectCall(String method, Object[] args);
>
> You can still programmatically generate the runtime xpath and then
> call the
> above method to Selenium directly.
>
> For more elegant solutions, it would be great if Tellurium could
> support dynamic
> attributes in the UI module. For example, for your first question, if
> Tellurium UDL
> could define some attributes as dynamic and do lazy binding at
> runtime, your problem
> could be solved. But to be honest, I haven't thought of such use cases
> yet. I will
> think it over and try to add this feature to UDL and core.
>
> For your second question, Tellurium provides the following method
>
> UiByTagResponse getUiByTag(String tag, Map filters);
>
> to return temporal uids for the giving tag and attributes. Then you
> can use these uids
> in the same way as other predefined uids in a UI module. More details
> here,
>
> http://code.google.com/p/aost/wiki/Tellurium070Update#Get_UIs_by_Tag_Name
>
> I will follow up with you about my thoughts of dynamic attributes in
> UDL and core.
>
> Thanks,
>
> Jian
>
> On Apr 7, 9:57 pm, tetsuo <[email protected]> wrote:
> > Hi All,
> >
> > My company is considering migrating from Selenium to Tellurium for one
> > of our projects. However we are a little concerned about losing some
> > test functionality that is currently enjoyed through the utilization
> > of plain old Selenium. I would like to give some examples of the test
> > functionality and then pose the question – how can I replicate this
> > test functionality using Tellurium?
> >
> > Example A - Verifying the content of a key/value pair table
> >
> > I have a sequence of key/value pairs loaded from a test data file into
> > a groovy map like so:
> >
> > ['AAA': '111',
> > 'BBB': '222',
> > 'CCC': '333']
> >
> > These pairs represent the expected content of a table to be tested,
> > they might be rendered in html like so:
> >
> > <table class='keyValueTable'>
> > <tr>
> > <td>AAA</td><td>111</td>
> > </tr>
> > <tr>
> > <td>BBB</td><td>222</td>
> > </tr>
> > <tr>
> > <td>CCC</td><td>333</td>
> > </tr>
> > </table>
> >
> > Using Selenium I can programmatically generate the xpath for each key/
> > value pair and assert the presence of the xpath.
> >
> > String cellType = "td";
> > String tableLocator = "//tab...@id='" + tableId + "']";
> > String valueLocator = tableLocator + "//" + cellType +
> > "[...@class='label' and .='" + key + "']/following-sibling::"+ cellType;
> >
> > Using Tellurium, how could I assert that the pairs in my test data
> > exist in the html table, considering that:
> >
> > • The order of the pairs in the test data does not necessarily
> > represent the order of the pairs in the rendered html
> > • The test data files may be updated frequently, i.e. one day there
> > may be 10 pairs, then the next there may be 30, and the new pairs
> > won’t necessarily be appended to the end of the test file.
> > • I don’t want to define each and every pair as elements within a UI
> > module, the test must be data driven.
> > • The order of pairs in the test data may change i.e. referencing
> rows
> > by index is too brittle.
> >
> > Example B - Utilisation of programmatically generated element ids
> >
> > Using Selenium if I have an element that I wish to interact with and I
> > need to generate a unique id attribute for the element I can
> > programmatically generate the id and then compose some xpath to
> > reference said element. For example, if I have a series of links with
> > composite ids:
> >
> > <a id=”111_222”>View</a>
> > <a id=”333_444”>View</a>
> > <a id=”555_666”>View</a>
> >
> > And my test data file looks like this
> > 111|222
> > 333|444
> > 555|666
> >
> > Using Selenium I would programmatically generate the xpath locators:
> >
> > //inp...@id='${idLeft}_${idRight}']
> >
> > And interact with the links using Selenium commands and the generated
> > xpath.
> >
> > Some questions:
> >
> > 1. How could I interact with these links using Tellurium (must be
> data
> > driven)
> > 2. Does the Tellurium API allow me to call Selenium commands
> directly?
> >
> > I guess the crux of this post is about dynamic attributes in Tellurium
> > tests. I really like the clean representation of the relevant parts of
> > a DOM that Tellurium Modules bring, but I can't see how I can perform
> > data driven testing with what appears to be largely static DOM
> > definitions.
> >
> > Regards,
> >
> > Graham
>
> --
> 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]<tellurium-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/tellurium-users?hl=en.
>
>
--
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.