Letractively / aost

Automatically exported from code.google.com/p/aost
Other
1 stars 0 forks source link

Add dynamic attributes support in UDL and Core in 0.8.0 #421

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi All,

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 = "//table[@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:

//input[@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.

Original issue reported on code.google.com by John.Jian.Fang@gmail.com on 8 Apr 2010 at 3:25

GoogleCodeExporter commented 9 years ago
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

Original comment by John.Jian.Fang@gmail.com on 8 Apr 2010 at 3:25

GoogleCodeExporter commented 9 years ago

Original comment by John.Jian.Fang@gmail.com on 19 Apr 2010 at 7:16