i see myself doing this in my test cases:
ArrayList bodyList = this.getSelectorFunctionCall(".bodyClazz",
'''
var list = [];
var children = this.children("a");
children.each(function(i, n){
list.push({"id":this.id, "text":$(this).text(), "num":i});
});
return list;
''');
int count = 0;
for(Map map : bodyList){
ui.InputBox(uid: "item[$count]", clocator: [id:map.id]);
ui.InputBox(uid: "input[$dropdownCount]", clocator:
[id:"input_"+map.dd]);
dropdownCount++;
}
this makes me wish that a locator could take a closure, which would
return a map, or an array list of maps, which would create the locator
for me. something like this:
ui.InputBox(uid: "item[${INDEX_PLACEHOLDER}]", jqlocator:
[selector:".bodyClazz" , func: '''
var list = [];
var children = this.children("a");
children.each(function(i, n){
list.push({"id":this.id, "text":$(this).text(), "num":i});
});
return list;
''']);
this would create item[1] ... item[N] with the attributes which i
pushed into "list" in javascript, these attributes would be populated
in a single call, and if i ever requested them again, i wouldnt need
to make a call to selenium in order to get them.
Ofcourse, this will break if the backing html is ever updated, but if
we know this in advance, we can program around it
On Dec 4, 3:24 pm, Mikhail Koryak <[EMAIL PROTECTED]> wrote:
> whatever way you want to add the user extensions in is fine with me,
> as long as it works. also, the selenium jar that i commited was hacked
> to work with *firefox in firefox3, you may want to back it out.
>
> On Dec 4, 3:12 pm, [EMAIL PROTECTED] wrote:
>
> > There are other options there, either start the selenium server using
> > command like
>
> > java -jar selenium-rc.jar -userExtensions user-extension.js
>
> > or we can use some code similar to
>
> > seleniumServer = new SeleniumServer(4444, false, true);
> > seleniumServer.start();
> > seleniumServer.addNewStaticContent(new File("/you_path/user-
> > extensions.js"));
>
> > We may like to update Tellurium to add the path for user-
> > extensions.js.
>
> > If you really need the user-extensions.js inside selenium-server.jar,
> > I can
> > add that to the ant build script for you later. But I like to separate
> > the user-extensions.js
> > out from selenium-server.jar.
>
> > I will check out your code tonight and see if I can add the user-
> > extensions.js path
> > for you.
>
> > Thanks,
>
> > Jian
>
> > On Dec 4, 2:23 pm, Mikhail Koryak <[EMAIL PROTECTED]> wrote:
>
> > > it might be good, if someone who is good at ant, would write an ant
> > > script that will take user-extensions.js and shove it into selenium-
> > > server.jar, since i will need to work with adding new scripts to user-
> > > extensions.js and right now its a somewhat manual process
>
> > > On Dec 4, 10:55 am, [EMAIL PROTECTED] wrote:
>
> > > > The locator language may be hidden from users and they do not really
> > > > need to know
> > > > about the language. What they really see will be the methods defined
> > > > in the DslContext
> > > > class. The locator language may only be used internally.
>
> > > > Anyway, please commit your code and add some tests or examples, then
> > > > we can discuss
> > > > further.
>
> > > > Thanks,
>
> > > > Jian
>
> > > > On Dec 4, 10:44 am, Mikhail Koryak <[EMAIL PROTECTED]> wrote:
>
> > > > > Re: locator language
> > > > > It sounds like an interesting idea, but you will need to sell it to
> > > > > better. what can it do that jquery selectors cannot do? with plain
> > > > > jquery selectors you can accomplish a lot, and a LOT of poeple already
> > > > > know jquery, which in turn will make it easier for them to get started
> > > > > with tellurium.
>
> > > > > On Dec 4, 10:34 am, [EMAIL PROTECTED] wrote:
>
> > > > > > I am very glad to hear that. We need to create the Engine project.
>
> > > > > > Matt, do you have time to create a new Engine project in the trunk
> > > > > > and
> > > > > > update the pom files?
>
> > > > > > Thanks,
>
> > > > > > Jian
>
> > > > > > On Dec 4, 10:30 am, Mikhail Koryak <[EMAIL PROTECTED]> wrote:
>
> > > > > > > yes, i think its doable, i think we are talking about the same
> > > > > > > thing
> > > > > > > actually. ill try to commit my code soon.
>
> > > > > > > On Dec 4, 10:22 am, [EMAIL PROTECTED] wrote:
>
> > > > > > > > Mikhail,
>
> > > > > > > > Please commit your code to
> > > > > > > > https://aost.googlecode.com/svn/branches/core-jlocator
> > > > > > > > so that I and other team members can take a look.
>
> > > > > > > > To be able to support multiple elements, we may have to modify
> > > > > > > > the
> > > > > > > > selenium
> > > > > > > > core or we should start our own Engine project earlier so that
> > > > > > > > we will
> > > > > > > > not
> > > > > > > > be constrained by Selenium implementation. Would it be possible
> > > > > > > > for us
> > > > > > > > to start
> > > > > > > > the Engine project in an agile way, that is to say, for most
> > > > > > > > regular
> > > > > > > > calls from
> > > > > > > > Tellurium to Selenium, we still use Selenium core. But for your
> > > > > > > > jquery
> > > > > > > > selectors
> > > > > > > > and multiple element support, we start to write a small engine
> > > > > > > > that
> > > > > > > > only includes the
> > > > > > > > extra methods you provide. How much effort if we do in this way
> > > > > > > > and is
> > > > > > > > it doable?
>
> > > > > > > > Thanks,
>
> > > > > > > > Jian
>
> > > > > > > > On Dec 4, 9:50 am, Mikhail Koryak <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > I have been giving this more thought, let me know what you
> > > > > > > > > think about
> > > > > > > > > this:
>
> > > > > > > > > group locators should get the extra methods that i provide,
> > > > > > > > > because by
> > > > > > > > > definition they group a set of elements. right now, they are
> > > > > > > > > used to
> > > > > > > > > more precisely locate their enclosing elements, right? we can
> > > > > > > > > add
> > > > > > > > > these extra methods to them and let these methods act on all
> > > > > > > > > elements
> > > > > > > > > that the locator groups. also, we can provide an optional
> > > > > > > > > argument to
> > > > > > > > > the methods called 'filter' which will filter the grouped set.
>
> > > > > > > > > On Dec 3, 11:09 pm, Mikhail Koryak <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > its possible to dynamically create jquery selectors, but
> > > > > > > > > > since all
> > > > > > > > > > current locators will select a single element, the
> > > > > > > > > > generated jquery
> > > > > > > > > > selectors will also locate a single element. since jquery
> > > > > > > > > > selectors
> > > > > > > > > > and xpath locators at the end do the same thing - select
> > > > > > > > > > some
> > > > > > > > > > elements.
>
> > > > > > > > > > most of the time, i will use a clocator that looks like this
> > > > > > > > > > [id:"someid", name:"somename"] - it has to locate a single
> > > > > > > > > > element, or
> > > > > > > > > > none of the selenium methods will work correctly, right?
> > > > > > > > > > ive never
> > > > > > > > > > tried to make a clocator that will use a class name only.
> > > > > > > > > > what is the
> > > > > > > > > > outcome of that? i dont think it will work.
>
> > > > > > > > > > that is the problem, we cannot dynamically make a locator
> > > > > > > > > > that locates
> > > > > > > > > > a single element, locate mulitples... unless.. we can use a
> > > > > > > > > > group
> > > > > > > > > > locator, and try to act on the entire group of all elements
> > > > > > > > > > under that
> > > > > > > > > > element.. ?
>
> > > > > > > > > > On Dec 3, 3:24 pm, [EMAIL PROTECTED] wrote:
>
> > > > > > > > > > > You have very good point here. Is it possible for you to
> > > > > > > > > > > dynamically
> > > > > > > > > > > create
> > > > > > > > > > > the JQuery selectors based on a set of
> > > > > > > > > > > criteria/attributes passed in?
> > > > > > > > > > > Then
> > > > > > > > > > > you may not have the limit of one locator maps to one
> > > > > > > > > > > element by
> > > > > > > > > > > treating
> > > > > > > > > > > the set of criteria/attributes as a special locator. That
> > > > > > > > > > > is to say,
> > > > > > > > > > > we only
> > > > > > > > > > > pass in a special locator and under the hood, you will
> > > > > > > > > > > generate
> > > > > > > > > > > multiple
> > > > > > > > > > > ones at the js level. Let me know if I understand the
> > > > > > > > > > > question
> > > > > > > > > > > correctly or not.
>
> > > > > > > > > > > I agree, we may only need to return multiple objects on
> > > > > > > > > > > your new
> > > > > > > > > > > methods.
>
> > > > > > > > > > > On Dec 3, 2:27 pm, Mikhail Koryak <[EMAIL PROTECTED]>
> > > > > > > > > > > wrote:
>
> > > > > > > > > > > > I think you may have misunderstood. I am not talking
> > > > > > > > > > > > about anything at
> > > > > > > > > > > > the java level when i say a locator cannot return
> > > > > > > > > > > > multiple elements.
> > > > > > > > > > > > at the selenium js level, a locator can only return 1
> > > > > > > > > > > > element, except
> > > > > > > > > > > > for the table locator, but that is a special case, and
> > > > > > > > > > > > uses a subset
> > > > > > > > > > > > of selenium-core methods not used by the rest of the
> > > > > > > > > > > > locators.
> > > > > > > > > > > > so, let us agree that any locator must return a single
> > > > > > > > > > > > element, unless
> > > > > > > > > > > > we heavily modify selenium-core (i think it will take a
> > > > > > > > > > > > rewrite).
>
> > > > > > > > > > > > so, currently all tellurium locators return a single
> > > > > > > > > > > > element.
> > > > > > > > > > > > my new methods work best if you pass in a jquery
> > > > > > > > > > > > selector that will
> > > > > > > > > > > > select multiple elements. Under the hood, i added a new
> > > > > > > > > > > > location
> > > > > > > > > > > > strategy, ie a new locator which actually returns
> > > > > > > > > > > > multiple elements,
> > > > > > > > > > > > but it is only used by my user-extension methods, so it
> > > > > > > > > > > > does not break
> > > > > > > > > > > > anything.
>
> > > > > > > > > > > > so, it looks to me that we cannot add my new methods to
> > > > > > > > > > > > any UiObjects
> > > > > > > > > > > > because every UiObject provides a locator, as you
> > > > > > > > > > > > mentioned above, and
> > > > > > > > > > > > these locators can only return a single element.
> > > > > > > > > > > > Ofcourse, my new methods can remain as methods of
> > > > > > > > > > > > DslContext, and
> > > > > > > > > > > > maybe that is the right thing to do for now.
>
> > > > > > > > > > > > to illustrate what i mean, here is the user-extension
> > > > > > > > > > > > for one of the
> > > > > > > > > > > > methods:
>
> > > > > > > > > > > > Selenium.prototype.getSelectorText = function(jq){
> > > > > > > > > > > > var e =
> > > > > > > > > > > > this.browserbot.findElement("jqueryall="+jq); //use a
> > > > > > > > > > > > custom
> > > > > > > > > > > > locator that returns a jquery wrapped set given a
> > > > > > > > > > > > jquery selector
> > > > > > > > > > > > var out = [];
> > > > > > > > > > > > for(var i = 0; i < e.length; i++){ //iterate
> > > > > > > > > > > > over the entire wrapped
> > > > > > > > > > > > set, and collect information into an array
> > > > > > > > > > > > out.push($(e[i]).text()); //using jquery
> > > > > > > > > > > > }
> > > > > > > > > > > > return JSON.stringify(out); //stringify the
> > > > > > > > > > > > list and return to client
> > > > > > > > > > > > where it will be parsed back into a list
>
> > > > > > > > > > > > };
>
> > > > > > > > > > > > i see a lot of power in being able to craft a jquery
> > > > > > > > > > > > selector that
> > > > > > > > > > > > selects multiple elements, and gathering information
> > > > > > > > > > > > from ALL of them
> > > > > > > > > > > > in one call.
>
> > > > > > > > > > > > On Dec 3, 1:20 pm, [EMAIL PROTECTED] wrote:
>
> > > > > > > > > > > > > The UiObject contains one locator, which could be
> > > > > > > > > > > > > BaseLocator,
> > > > > > > > > > > > > CompositeLocator,
> > > > > > > > > > > > > or the JQueryLocator you define. It is fine to return
> > > > > > > > > > > > > an array of
> > > > > > > > > > > > > objects from
> > > > > > > > > > > > > one locator. For example, you may return an ArrayList
> > > > > > > > > > > > > for a table row
> > > > > > > > > > > > > and you
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---