From: Pg <pg...@ad...> - 2003-09-16 03:34:09
|
Hi again! First of all, thanks for the answer Mike!. Now, I explain better my problem: Suppose you have an image, and a button whose "onClick" event changes that image into another image (chang= es the src Image property). I mention the "onClick" event for no special reason, it could be the "onMouseOver" event, for the same for the main porpouse. What I want is to simulate this, and verify that the image effectively changed. What I have tried to do is this: a) Obtain the "onClickAttribute" of the Button, (HtmlButton), using the "getOnClickAttribute" method, (suppose that the result string it`s just = a single javascript instruction, like: << document.Image1.src =3D 'draw1.jpg;'>>= , to simplify the situation). b) Invoke the "executeJavaScriptIfPossible" method of the HtmlPage page class, whith th= e following paramameters: sourceCode =3D t= he string obtained in a). sourceName =3D "SourceName1". wrapSourceInFunction =3D false. Scope =3D null. What I thought, is that in the page returned whitin the ScriptResult Object, I would see the property change doing this: asking for the Image, and then asking for the "onClick" value. =46rom the answer you gave me before, I see now that I won't see that cha= nge in the ScriptResult Object, because no new page is loaded. My question is: How can I simulate the click (without using the click method of the HtmlButton class), and then verify that the Image1.src property has effectively changed?. In other words: How can I simulate an event that doesn't create a new window, but changes things of the actual page, and verify the correctness= of those changes?. Thank you very much, and sorry for the message size!. Pablo Gallo. ----- Original Message ----- From: "Mike Bowler" <mb...@Ga...> To: <htm...@li...> Sent: Sunday, September 14, 2003 9:37 PM Subject: Re: [Htmlunit-user] How can i call a javascript function?? > Pg wrote: > > I'm trying to "simulate" a navigation over a Html page. So, if an > > element in the page has an associated event (like onmouseover), I wa= nt > > to run the Javascript code associated (if exists) with this event. > > I tried using the Htmlpage.executeJavaScriptIfPossible method in thi= s > > way: > > > > Htmlpage.executeJavaScriptIfPossible( javascript_code, message, fals= e, > > null) > > > > Here is the code: > > > > ScriptResult sr =3D > > page.executeJavaScriptIfPossible("document.Form1.Input1.value =3D > > 'go!';", "error in go!", false, null); > > > > The problem is that the new page I obtained in the ScriptResult Obje= ct > > returned by the the previous operation doesn't differ at all from th= e > > original page, when I was expecting a different value in the > > Form1.Input1.value attribute: 'go!'. This operation doesn=B4t throw = any > > exception, it just pass..... but there`s no differences!!. > > The page returned in the ScriptResult will only be different if a new > page was loaded as a result of executing the javascript. In this case, > no new page will be loaded so the same page should be returned. > > I don't see anything wrong with the code you have provided - I would > have expected this to work. Can you provide a more complete sample? > > -- > Mike Bowler > Principal, Gargoyle Software Inc. > Voice: (416) 822-0973 | Email : mb...@Ga... > Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |