Auto-fulfilled controls on page

13 views
Skip to first unread message

Sergey Buslov

unread,
May 18, 2007, 3:16:45 AM5/18/07
to SWExplorerAutomation
Hi Alex,

I wonder if swea provides a solution for button/mouse click imitation
so that appropriate events are raised on the page and processed by
their scripts.

What I need exactly. I use swea for entering value into one of the
edit controls on web form and expect another text control to be
fulfilled automatically based on the value I entered. When doing this
manually - it works fine: once I've enter the value into the edit box,
appropriate text box is fulfilled also. When using swea to set value
into edit control, the text control remains empty, as if there were no
values entered...

I tried to imitate button event but failed. There is an edit control,
called 'StakeValue' in my htp project. Below is what I have tried:

scene.HtmlInputText("StakeValue").Value = AmountToBeStaked; // This
does fulfill the edit control, but does not force appropriate script
to execute and fulfill the textbox.

I have tried the following methods also:
scene.HtmlInputText("StakeValue").Invoke("Method_Focus");
scene.HtmlInputText("StakeValue").Invoke("Method_OnKeyDown");
scene.HtmlInputText("StakeValue").Invoke("Method_OnChange");
scene.HtmlInputText("StakeValue").Invoke("Method_OnKeyUp");
scene.HtmlInputText("StakeValue").Invoke("Method_OnKeyPress");

But none of these seem to work...

Any repond from you is highly appreciated.

Thanks in advance,
Sergey

alex

unread,
May 18, 2007, 4:16:21 PM5/18/07
to SWExplorerAutomation
Hi Sergey,

SWEA does support mouse simulation. You can record simulated Mouse
event from the "conrol view/invoke" tab.

You can find out which event was used by using SWEA DOM Navigator. It
may be the focus event which was used to fill the field.

We are also adding SendKeys function in the next release. It will
simulate the keyboard events.

Regards,
Alex Furman

Sergey Buslov

unread,
May 20, 2007, 5:35:44 AM5/20/07
to SWExplorerAutomation
Hi Alex,

Thank you for quick response!

I can clearly see that the event used for fulfilling the text field is
'KeyUp' - I made this conclusion because if I press key manually and
coninue keeping it pressed for a while textbox remains empty, then,
right after I unpress the key - appropriate info is displayed in
textbox.

I tried the focus() even but it did ot help... Mouse events also seem
to be helpless. One more thing: after clicking 'Invoke' button (on
ControlView tab) there is no response from the site...

So it seems like the only way to make site react is to use the
keyboard events... I wonder if it would be possible to add the
keyboard events support as a service park to the current version? If
no, could you please give some rough estimations regarding the next
planned release date?

Thanks,
Sergey

Alex Furman

unread,
May 20, 2007, 8:42:21 PM5/20/07
to swexplorer...@googlegroups.com
Hi Sergey,

You can try the latest 1.9.3.1 version. We have added the SendKeys function
which simulates the keyboard events.

Best Regards,
Alex Furman

Sergey Buslov

unread,
May 22, 2007, 2:38:07 AM5/22/07
to SWExplorerAutomation
Hi Alex,

Yes, that works with me just fine! Thanks a lot Alex!

May I ask one minor question in this thread also... I tried to look
through the swea API but failed to find this, I must be missing
something :( WhatI am looking for is a way to refresh the page
displayed. I mean, if I open the same htp project several times and
navigate to the same URL the page may remain unchanged (cashed in
cookies?) and I need to somehow refresh this programmatically. I tried
playing with scene.RuntimeSceneInfo.Cookie,
explorerManager.Reidentify() and
scene.HtmlContent(sName).TableDataExtractor.Refresh() as I deal with
table data, but none of these seem to refresh the page..

Thanks again, you are of a great help!

Thanks,
Sergey

Alex Furman

unread,
May 22, 2007, 8:08:57 AM5/22/07
to swexplorer...@googlegroups.com
Hi Sergey,

SWEA doesn't cache pages. Does the page refresh when you restart the IE?

Sergey Buslov

unread,
May 22, 2007, 10:59:19 AM5/22/07
to SWExplorerAutomation
Hi Alex,

The page is refreshed if I do ith manually in explorer (e.g. pressing
F5).

The way I use it through the SWEA is: I create a new instance of swea
manager, open appropriate project, call Connect() and navigate to the
URL. Then disconnect from the page (without closing it) and repeat the
same steps with the diffeence that now I connect to the currently
opened IE process.

Thanks,
Sergey

Alex Furman

unread,
May 22, 2007, 11:11:41 AM5/22/07
to swexplorer...@googlegroups.com
Hi Sergey,

You can refresh the browser by using IWebBrowser2
interface(http://msdn2.microsoft.com/en-us/library/aa768258.aspx). You will
need to add reference to SHDocVw(COM component named Microsoft Internet
Controls).

Example:

((SHDocVw.IWebBrowser2)explorerManager.GetBrowserInfo(scene.RuntimeSceneData.HWND)).Refresh();

or

((SHDocVw.IWebBrowser2)explorerManager.GetBrowserInfo(explorerManager.GetExplorerWindows()[0]).Refresh();

Regards,
Alex Furman

_________________________________________________________________
Catch suspicious messages before you open them—with Windows Live Hotmail.
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_protection_0507

Sergey Buslov

unread,
May 22, 2007, 4:38:50 PM5/22/07
to SWExplorerAutomation
Hi Alex,

Thanks again, that seems to do the trick.

One thing though. I had to modify your code a bit to make it workabe:
in particular I had to get Browser object from BrowserInfo, and then
cast it to the IWebBrowser2 (I am sure you did mean this when
answered).

So to make your code compilable and workable we need the following
slight changes (placing here for possible future reference...):

Example (corrected):

((SHDocVw.IWebBrowser2)explorerManager.GetBrowserInfo((IntPtr)scene.RuntimeSceneInfo.HWND).Browser).Refresh();

or

((SHDocVw.IWebBrowser2)explorerManager.GetBrowserInfo(explorerManager.GetExplorerWindows()
[0]).Browser).Refresh();

Again, many thanks to your answers!

Thanks,
Sergey

On May 22, 6:11 pm, "Alex Furman" <alex_f...@hotmail.com> wrote:
> Hi Sergey,
>

> You can refresh the browser by using IWebBrowser2
> interface(http://msdn2.microsoft.com/en-us/library/aa768258.aspx). You will
> need to add reference to SHDocVw(COM component named Microsoft Internet
> Controls).
>
> Example:
>
> ((SHDocVw.IWebBrowser2)explorerManager.GetBrowserInfo(scene.RuntimeSceneDat a.HWND)).Refresh();
>
> or
>

> ((SHDocVw.IWebBrowser2)explorerManager.GetBrowserInfo(explorerManager.GetEx plorerWindows()[0]).Refresh();

> Catch suspicious messages before you open them-with Windows Live Hotmail.http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_m...- Hide quoted text -
>
> - Show quoted text -

Sergey Buslov

unread,
Jul 16, 2007, 4:17:57 AM7/16/07
to SWExplorerAutomation
Hi Alex,

I regret to say that SendKey function does not always work properly on
my side.

In particular, I cannot understand why, but sometimes the keys I have
sent to the control incorrectly get entered into the address bar of
the web browser.

E.g. I use the following code for sending a key to the control:
scene.HtmlInputText("StakeValue").Invoke("Method_SendKeys",
"{KEY_CODE}");
where {KEY_CODE} is a code of the symbol, or symbol itself. In my case
I use left button code, e.g. {LEFT} and for some reason on the odds
time this combination {LEFT} is entered in the address bar of the
browser, although expected behavior is just to press left button on
the control specified. This is not a permanent behavior and sometimes
these keys do go to the valid control...

As a matter of fact, all I need to do is just to imitate the KeyUp
event for the key entered and I wonder whether it would be possible to
have support for the following events via swea:


scene.HtmlInputText("StakeValue").Invoke("Method_OnKeyDown");
scene.HtmlInputText("StakeValue").Invoke("Method_OnChange");
scene.HtmlInputText("StakeValue").Invoke("Method_OnKeyUp");

so that I could enter necessary value using Value property of the
control and then notify the web page about KeyUp event?

Thanks in advance,
Sergey

> > Catch suspicious messages before you open them-with Windows Live Hotmail.http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_m...Hide quoted text -

Alex Furman

unread,
Jul 16, 2007, 9:51:42 PM7/16/07
to swexplorer...@googlegroups.com
Hi Sergey,

There is no simple solution answer to the problem. SWEA relies on Windows
API (SendInput function) to send character strings. It is most reliable way
to simulate the keyboard. You can also simulate windows events (WM_KEYDOWN,
WM_KEY_UP), but I have found the method is less reliable.

The most reliable way is to directly call the event function on the element:
scene.HtmlInputText("StakeValue").Invoke("Method_OnChange"), but it may not
work in your case.

Can I reproduce you problem?


Best Regards,
Alex Furman

-----Original Message-----
From: swexplorer...@googlegroups.com
[mailto:swexplorer...@googlegroups.com] On Behalf Of Sergey Buslov
Sent: Monday, July 16, 2007 4:18 AM
To: SWExplorerAutomation
Subject: Re: Auto-fulfilled controls on page


Hi Alex,

I regret to say that SendKey function does not always work properly on

Reply all
Reply to author
Forward
0 new messages