Mouseover click ?

Questions and answers about anything related to Helium Scraper
derba
Posts: 27
Joined: Tue May 15, 2012 8:03 pm

Mouseover click ?

Post by derba » Mon May 21, 2012 9:05 am

Hi,

I have a lot of similar buttons to make Helium click. The usual strategy (create kind + in action "navigate & simulate click") is not working here.

I have taken the liberty to copy and adapt below the same html code problem that was encoutered on another software forum (http://translate.google.com/translate?s ... 2F&act=url) :

There is a page on which the top of the login dialogue is present, the code for the button looks like this:

Code: Select all

 <tr>
  <td align="left" style="vertical-align: top;">
    <div id="button" class="gwt-PushButton gwt-PushButton-up" tabindex="0" role="button" aria-pressed="false">
     <input type="text" tabindex="-1" style="opacity: 0; height: 1px; width: 1px; z-index: -1; overflow: hidden; position: absolute;">
    <div class="html-face" style="background-color: transparent;"> Login </ div>
   </ Div>
  </ Td>
 </ Tr>

When the cursor pointing at it, the line changes:

Code: Select all

<div id="button" class="gwt-PushButton gwt-PushButton-up-hovering" tabindex="0" role="button" aria-pressed="false">


When you press a button, without releasing the mouse button, the code changes:

Code: Select all

 <div id="button" class="gwt-PushButton gwt-PushButton-down-hovering" tabindex="0" role="button" aria-pressed="true">
As you see there are two differences:
up => down
and
false => true

I have use a Text gatherer to make the html change ok (I named it "JS_changes") :

Code: Select all

var step0_result = element.outerHTML.replace(/\r\n/g, "\n");
var step1_result = step0_result.replace(new RegExp("aria-pressed=false", "g"), "aria-pressed=true");

var step2_result = step1_result.replace(new RegExp("gwt-PushButton\\ gwt-PushButton-up", "g"), "gwt-PushButton gwt-PushButton-down");

return step2_result;

In action I added the following :
select kind with the log in button
javascript code:

Code: Select all

var dropDown = Global.Browser.Selection.GetItem(0);
window.location.href = Global.Gather("JS_changes", dropDown);
This is where I think I am wrong ! In the other forum the solution seems to be something like :
The result was a list of commands:
mouseOver / / * [@ id = "button"]
mouseDown / / * [@ id = "button"]
mouseUp / / * [@ id = "button"]

or
selenium. mouseOver ("locator");
selenium.click ("locator");


Many thanks in advance ;)

derba
Posts: 27
Joined: Tue May 15, 2012 8:03 pm

Re: Mouseover click ?

Post by derba » Tue May 22, 2012 10:57 am

Hi,
I am still digging trying to find a way for Helium to click those buttons !

I think the problem comes from the push button as I failed to create a valid kind and click action : the button doesn't show "Get Off!" (see my enclosed file
test_click_on_push_button.hsp
(501.28 KiB) Downloaded 718 times
)
Here a test url :
http://examples.roughian.com/index.htm# ... PushButton
In my cases the buttons (login etc...) are loading (I assume) a new url or something of that sort! as a new browser action is done once I have clicked on the button...)

(note: the aria true to false is not the problem as I successfully created a kind with that test code :
http://websiteaccessibility.donaldevans ... ia-button/ )

I hope this help.
Thanks in advance ;)

webmaster
Site Admin
Posts: 521
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Re: Mouseover click ?

Post by webmaster » Tue May 22, 2012 5:00 pm

Try this.
Attachments
click.hsp
(504.84 KiB) Downloaded 694 times
Juan Soldi
The Helium Scraper Team

derba
Posts: 27
Joined: Tue May 15, 2012 8:03 pm

Re: Mouseover click ?

Post by derba » Wed May 23, 2012 9:00 am

Hi Juan,

Many thanks. Your attachment is working great with my example. ;)

Alas I failed to reproduce your success in the website that I would like to scrape (it is using https : the button may be simply linked to the secured page - which should not be a problem I assume http://www.pcreview.co.uk/forums/add-pa ... 65472.html).

Here is another example (I believe closer !) :
http://www.w3schools.com/jsref/tryit.as ... srcelement

Here is the related Helium file :
click_02.hsp
(505.64 KiB) Downloaded 678 times
I would like that Helium makes the alert box appearing when clicking on the text "This is a heading" (or the text "This is a paragraph").

Many thanks in advance ;)

webmaster
Site Admin
Posts: 521
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Re: Mouseover click ?

Post by webmaster » Thu May 24, 2012 2:35 am

Hi,

The reason why is not wirking on w3schools is because the image is inside an iFrame. If you look at the TAG element of the kinds you created you'll see they are actually selecting the iFrame element, not the content. You need to navigate inside the iFrame before being able to select any element. Here is a Go To IFrame premade project that will help you do that automatically.

Regarding the other site, which button are you trying to click?
Juan Soldi
The Helium Scraper Team

derba
Posts: 27
Joined: Tue May 15, 2012 8:03 pm

Re: Mouseover click ?

Post by derba » Thu May 24, 2012 9:59 am

Hi Juan,
webmaster wrote:The reason why is not wirking on w3schools is because the image is inside an iFrame. If you look at the TAG element of the kinds you created you'll see they are actually selecting the iFrame element, not the content. You need to navigate inside the iFrame before being able to select any element. Here is a Go To IFrame premade project that will help you do that automatically.
Many thanks. Indeed your solution works great for the iframe problem of this link http://www.w3schools.com/jsref/tryit.as ... srcelement ;)

But for my website it is still not working (Looking inside the html with the addon Firebug in Firefox I have discovered that I have two iframe but the buttons are not located as children of them. So iframe may not be the problem in fact ?!)
Anyway, I hope that I have now found why :
There is a "prevent right-click" added in the code of the website I would like to scrap !
The code is :

Code: Select all

<body oncontextmenu="return false;">
In order to make a test, I have added the code of this webpage (I assume it contains the "<body oncontextmenu="return false;">" code http://www.users.totalise.co.uk/~bigole ... click.html) and the iframe content of that page (http://www.w3schools.com/jsref/tryit_vi ... srcelement) to the file "example.htm"
It can be downloaded here :
http://www.sendspace.com/file/b3mcuu

When I add (grab) the "example.htm" file to Helium Scraper and run the mouseover solution you have shared in your first post above ("click.hsp") I have the following alert box :
[object Error] (see image below). note: If I do a right click test in the Helium browser I have 2 correct alert boxes as a result. ;)
example_object_error.jpg
example_object_error.jpg (155.1 KiB) Viewed 17640 times

Maybe this link will help for a solution ("javascript:void oncontextmenu(null)" http://javascript.about.com/library/blnoright.htm) ?

Many thanks in advance ;)

webmaster
Site Admin
Posts: 521
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Re: Mouseover click ?

Post by webmaster » Thu May 24, 2012 5:18 pm

Hi,

That error message was my bad. Double click all the Execute JS actions and replace the line

Code: Select all

alert(error);
for

Code: Select all

alert(error.message);
and now you'll get a meaningful message. The actual error was that no item was selected because the demo-PushButton kind wasn't finding the element. Also, I should have set the Select Kind action on top require exactly 1 element so that you get notified when the element is not found. Just double click it and select Require Exactly 1 item.

Try this and let me know how it goes. Perhaps the error will give you more details on the actual page you're trying to scrape.
Juan Soldi
The Helium Scraper Team

derba
Posts: 27
Joined: Tue May 15, 2012 8:03 pm

Re: Mouseover click ?

Post by derba » Fri May 25, 2012 6:50 am

Hi,
Your new (alert.message) code is working fine (I am not bothered by the "prevent right click" and the correct alert box are launched) with the file "example.htm". ;)

Alas it is still not working for the website I am targeting.
I was wondering if this from above may help ?
selenium. mouseOver ("locator");
selenium.click ("locator");
Which may be transformed in Helium by something like :
select kind
"Simulate click" (like in the "Navigate" action / instead of the onmousedown javascript ? )
note: I have noticed that when I click on the button(s) the result is appearing very fast (<1 second).

Thanks in advance,
ps: I'll PM you in a moment

webmaster
Site Admin
Posts: 521
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Re: Mouseover click ?

Post by webmaster » Fri May 25, 2012 6:00 pm

Hi,

This is a shot in the dark since I cannot test it, but try using a Select Kind action which selects your button (require 1 item), and add an Execute JavaScript action underneath with this code:

Code: Select all

try
{
	var button = Global.Browser.Selection.GetItem(0);
	button.fireEvent("onmouseover");
	button.click();
}
catch(error)
{
	alert(error.message);
}
(Alternatively, you could replace button.click(); for button.fireEvent("onclick"); or if this site uses jQuery, use $(button).mouseover(); instead of button.fireEvent("onmouseover"); and $(button).click(); instead of button.click();)

Make sure your kind selects the INPUT element and not a DIV or anything else (maybe an A element would be OK too). You can play with the Select Parent button in the selection editor until you get the INPUT selected.
Juan Soldi
The Helium Scraper Team

derba
Posts: 27
Joined: Tue May 15, 2012 8:03 pm

Re: Mouseover click ?

Post by derba » Sat May 26, 2012 8:26 am

Hi Juan,

Many thanks. Alas I have tried your different solutions without success.
You can play with the Select Parent button in the selection editor until you get the INPUT selected.
Thanks to your suggestion, I have noticed that the third INPUT is not detected by Helium if I use the https url !
But it is detected if I drag the htm file inside Helium with the following login code :

Code: Select all

<div class="gwt-PushButton gwt-PushButton-up" tabindex="0" role="button" style="position: absolute; left: 400px; top: 125px;" aria-pressed="false">
<input type="text" tabindex="-1" style="opacity: 0; height: 1px; width: 1px; z-index: -1; overflow: hidden; position: absolute;">
<div class="html-face">Log In</div>
</div>
See image here :
http://www.sendspace.com/file/7cytbg

If you open the htm file in Firefox and use right click "inspect with firebug (addon)" you will notice that if you select the INPUT row, it will highlight a little square.
See image here:
http://www.sendspace.com/file/iceciq
And if I select the "div class="gwt-PushButton gwt-PushButton-up" row (or the "html-face" row), it appears that the little square is taken over by its selection highlights.

Hope this helps ;)
Thanks in advance ;)

Post Reply