Sign in to follow this  
Followers 0
tommytx

How to apply getbyname to a framed item.

12 posts in this topic

#1 ·  Posted (edited)

Is there a special format to work on the object when it is in a frame. There are two frames on the page. The frame names are "topFrame" and "mainFrame". Using the code below does have any effect. I need either one to work, but have tried both to no avail. What I am trying to do is click a button in the mainFrame with the name "RADIUS SEARCH" and a html name=radius_button1

This msgbox is not required. I was just trying to see what the links looked like, but the msgbox never got tripped even once.

msgbox(0, "Link Click", $sLinkText)

Is there some frame addressing that I must add for the system to click the button.

Any suggestions would be greatly appreciated.

Attempt #1

**********

$tomboy = _IEGetObjByName ($oIE, "radius_button1")

_IEAction($tomboy, "click")

_IELoadWait ($oIE)

Attempt #2

**********

$sMyString = "RADIUS SEARCH"

$oLinks = _IELinkGetCollection($oIE)

For $oLink in $oLinks

$sLinkText = _IEPropertyGet($oLink, "innerText")

msgbox(0, "Link Click", $sLinkText)

If StringInStr($sLinkText, $sMyString) Then

_IEAction($oLink, "click")

ExitLoop

EndIf

Next

Not sure if this will be helpful but here is the button code:

<input type="Button" class="buttonnarrow" name="radius_button1" title="Click here for radius search" value="RADIUS SEARCH" onclick="getRadiusSearch();" />

Edited by tommytx

Share this post


Link to post
Share on other sites



Typically, $oIE is the top level document object. You have to drill down with something like _IEFrameGetObjByName() then use:

$tomboy = _IEGetObjByName ($oFrame, "radius_button1")

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Here is what I interpreted that you were saying, is this correct... However it did not work... any other ideas..pls?

$oFrame = "mainFrame"

$tomboy = _IEGetObjByName ($oFrame, "radius_button1")

_IEAction($tomboy, "click")

Share this post


Link to post
Share on other sites

Where did you put _IEFrameGetObjByName() in there anywhere?

$oFrame = _IEFrameGetObjByName($oIE, "mainFrame")
$tomboy = _IEGetObjByName ($oFrame, "radius_button1")
_IEAction($tomboy, "click")

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks... isn't that something.. I was just coming here to say I just tried this and it did not work either..

Perfect timing.. it looks identical to your code... but not workeee...

$oFrame = _IEFrameGetObjByName ($oIE, "mainFrame")
$tomboy = _IEGetObjByName ($oFrame, "radius_button1")
  _IEAction($tomboy, "click")

Share this post


Link to post
Share on other sites

That's a pretty sad failure analysis for a tech forum: "but not workeee" :blink:

How, exactly, did it "not workeee"?

Put _IEErrorHandlerRegister() near the top of your script and run it in SciTE to see the console output. See where it failed. If it found the frame but not the button, see if it's further buried. Maybe you have to get the frame, then a form, then the button inside the form.

If it found the button but "click" didn't seem to work, try the other methods listed in the help file (i.e. set "focus" then send "{ENTER}").

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Definition of "Not Workeeee..."

Since the entire post is about the fact that nothing happens when I attempt to click the button, so far none of the attempts have Clicked the button... so same problem... no workeee... still.. I really appreciate the help.. as I am not that quick...

I will go now and try the items you listed and hopefully one of them will work or shed enought light to get it going.

By the way.. when the button is clicked, it simply fires this script... and the script is in the same frame "mainFrame" does Autoit have the capability to activate the script direct and ignore the button all together?

function getRadiusSearch() {
    closePreviousWindow();
    var url = "http://www.mydomain.com/maps/RadiusSearch.aspx";
    var winHeight = 400;
    var winWidth = 340;
    var popName = "RadiusSearch";
    createDialogBox(url, winHeight, winWidth, popName);
}

Will let you know the results of the suggestions above... Thanks again..

Share this post


Link to post
Share on other sites

Another possibility when dealing with frames is that they might come from a different address space, which triggers cross site scripting protections. You would see that by getting "ACCESS DENIED" when trying to use objects in the frame.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I entered the error thing like this and it ran completely through with no errors..

and unloaded the program normally... but gave no indication that all was not well..

I am now playing with setting up the focus you suggested... I am still playing with how I will tell it to look in the mainFrame but not there yet.. I know its arriving at the button click spot, as I have added a Msgbox telling me it has arrived...

Haven't tried this yet.. but am working on it.

document.mainFrame.radius_button1.focus();

#include <IE.au3>

_IEErrorHandlerRegister() 

ShellExecute ("iexplore.exe", "about:blank")
WinWait ("Blank Page")
$oIE = _IEAttach ("about:blank", "url")
_IELoadWait ($oIE)
_IENavigate ($oIE, "www.mydomain.com")

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

That kind of sounds like you compiled it and ran the .exe.

You have to run that from SciTE with ctrl-F5 to see the output in the console (bottom) pane of the SciTE window.

:blink:

P.S. There's no point in creating the IE instance with ShellExecute() and then attaching to it. Just use _IECreate() from the beginning. It would look more like this:

#include <IE.au3>

_IEErrorHandlerRegister() 

$oIE = _IECreate("http://www.mydomain.com")
$oFrame = _IEFrameGetObjByName($oIE, "mainFrame")
$oButton = _IEGetObjByName($oFrame, "radius_button1")
_IEAction($oButton, "click")

;)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Still having a heck of a time trying to access a button for click.. It appears they are hiding access thru double loads. Does anyone have any idea why you would load the same file main_action.htm into to different frames only one of which show on the screen.... its got to be some anti-scrape feature wouldn't you say...

Is there a really great DOM tool that I could use to tell me exactly what the DOM format I will need to click this a button... is there a DOM viewer tool that is really excellent for seeing the exact position of an element in the DOM structure... and if anyone has any idea what the reason for a double load into two differnt frames.. please tell me.

It surely slows the process a little as the size of the file main_action.htm is 350k bytes...

<FRAMESET cols=25%,*>
<FRAMESET rows="43%, *">
<FRAME name=frameTop marginHeight=0 src="main_frame_files/search_title.htm" frameBorder=No>

<FRAME name=frameBottom marginHeight=0 src="main_frame_files/main_action.htm">
</FRAMESET>

<FRAME name=frameMiddle marginHeight=0 src="main_frame_files/main_action.htm">
</FRAMESET>

Share this post


Link to post
Share on other sites

DebugBar is recommended for IE. Or FireBug for Firefox. But there are many DOM Inspectors out there.

In what you just posted, the parent frameset doesn't have a name, so you would have to reference it by index. That frameset contains a child frameset (also without a name) and a frame named "frameMiddle". The child frameset contains two frames, named "frameTop" and "frameBottom". None of the frames shown is named "mainFrame".

You didn't say where in these nested frames your target button was located.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0