Brian,
Thank you so much for you response! Okay I am going to try this.
Question - is it possible for me to get a hold of an Ajax object and
send it clicks and text the way we get a hold of html elements?
I've posted the following thread up on a fellow Watij user (test
developer's page) who goes by Mushy, that illustrates where I am and
what I am trying to accomplish I think better than the posts I've put
up here so I'm going to copy it and past it into this thread. Here is
the post (the code examples I have do not show any of my wait
messages, I've been using .ie.waitUntilReadyInvokeLater(); and
ie.waitUntilReady() between most of my calls to the browser with good
results during the log in and send key ops). Anyway, here's the post:
"Mushy,
I am looking into AJAX Apps with an IE window as my primary focus.
After I can find these hidden controls using watij (which is where I
have been stumped) I will probably attempt to tackle some MS Word and
Excel customization testing if possible.
So, when I did my watij proof of concept I was merely opening a
browser to a URL, logging in, and sending some combo keys to create a
new object in Documentum. The sendkeys was sort of a desperate
attempt on my part to demonstrate watij's usability, but I'd rather
(and now realize I need to) actually get a handle on the target
control and send it a click event or populate a text field like I did
with the log in screen:
String aUrl = "
http://somelocation.com";
String aUserName = "me";
String aPassword = "mypassword";
IE ie = new IE();
User aUser = new User(ie);
aUser.setMyUrl(aUrl);
aUser.login(aUserName, aPassword);
=== user.login() ====================
myBrowser.start(myUrl);
myBrowser.textField(name,"Login_username_0").set(aUserName);
myBrowser.textField(name, "Login_password_0").set(aPassword);
myBrowser.waitUntilReady();
myBrowser.button(name, "Login_loginButton_0").click();
myBrowser.waitUntilReady();
===============================================
This is a nice bit of code if your webpage actually has html elements
like < button > or < input > or the like, but with this new interface
the only tags/elements I get are < script > < link > and some embedded
functions for event registration and stuff.
I've been reading the Watij group up on google and there are others
who appear to have gotten past the point that I'm on, but gleaming my
solution from theirs is not as straight forward as I had hoped and my
java is pretty rusty adding to my challenge.
What I gather so far is that I may need to write my own finder and
that I need to get a handle on the document object which may contain
these hidden controls. So, I've been exploring ie.iWebBrowser2() and
the watij API for this and that's about where I am at.
If you have any examples of where you have written code that can grab
a non-html ajax like element and are able to populate it with text or
if it's a button send it a click, even better a pull down menu item,
selection list item etc., I would be greatly appreciating it :)
Thank you!
Chris"
So, apologies for the lengthy reading, and thank you again for your
advise. I am now going to see how I can leverage this example and
will likely report back to this thread in the hopes that my verbose
problem solution documentation can help others while I get to the
finish line. :)
Cheers!
Chris
On Jan 9, 9:37 am, "Brian Knorr" <
btkn...@gmail.com> wrote:
> Hi Chris,
>
> You can send actual javascript to the page via ie.executeScript which will
> evaluate it on the page (so the sky is the limit here).......also the best
> way to handle async javascript calls (ajax) is to use a waiter. For
> example:
>
> ie.link().click(); //fires an ajax call to update something
> new WaiterImpl(10000, 200).waitUntil(new Ready() {
> public boolean isReady() throws Exception {
> return ie.containsText("update successful"); //wait until the text
> is returned from the ajax call
> }
>
> public String getNotReadyReason() {
> return "control doesn't exist";
> }
>
> });
>
> Hope this helps...best,
>
> Brian
>
> > > I grab all of the html elements (ie.elements()) I get the following