Jump to content

Getting object IE - problem


daro
 Share

Recommended Posts

Hi everyone,

I am new here and this is my first post. I need some help with my code. What I want is to click on the "Logout" button, but I can't get handle to this. I think that this is becouce of the structure of the page: 

<html>
    <head>
        <frameset>
            <frame name="topFrame" ...>
                <!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" -->
                <html lang="en">
                    <head>
                        <body onload="MM_preloadImages('/sgd/resources/images/webtop/sgdhelp2.gif','/sgd/resources/images/webtop/sgdinfo2.gif','/sgd/resources/images/webtop/sgdlogout2.gif','/sgd/resources/images/webtop/edit.gif')">
                                <div id="bigDiv">
                                        <div id="miniDiv"> .... </>
                                        <div id="buttons">
                                                <a onmouseover="MM_swapImage('Logout','','/sgd/resources/images/webtop/sgdlogout2.gif',1)" onmouseout="MM_swapImgRestore()" onclick="return confirmLogOut()" href="logout.jsp">
                                                        <img name="Logout" width="69" height="77" id="logoutImg" alt="Logout" src="/sgd/resources/images/webtop/sgdlogout.gif" border="0" complete="complete"/>

I ve tried do this with  _IEGetObjByName() function, but no result. I also try this: _IEImgClick() but even when a put full path to the image, it still don't work.

After that I ve tried to do this in two steps:

1. Geting handle do the frame called "topFrame".

2. Use this handle in _IEFormImageClick() function.

And it's also doesn't work. I can only get frame object, nothing more. 

This is the part of my code:

;---------------Logging To WebTop---------------------------------------------------------------------------
_LogWrite($log_file_name, "Trying to opean WebTop in IE...")
local $oIE = RunIE("webpage")
local $success = LoginToWebTop2($oIE, $user, $password)
if ($success == 0)Then
    _LogWriteError($log_file_name, "Couldn't open WebTop in IE. Exit")
    Exit
Else
    _LogWriteSuccess($log_file_name, "WebTop Successfully opened.")
EndIf
Sleep(8000)
$frame = _IEGetObjByName($oIE,"topFrame")
If $frame == 0 Then
MsgBox(0, "Test", "Error ")
Else
MsgBox(0, "Test", "Success")
EndIf
$oButton = _IEFormImageClick($frame,"Logout","name")
If $oButton == 0 Then
MsgBox(0, "Test", "Error")
Else
MsgBox(0, "Test", "Success")

Do you have any ideas, how can I deal with it?

Thanks for any help,

Darek

Link to comment
Share on other sites

I ve tried this:

$frame = _IEGetObjByName($oIE,"topFrame")
If $frame == 0 Then
MsgBox(0, "Test", "Error")
Else
MsgBox(0, "Test", "Success - you have frame handle")
EndIf
$oButton = _IEFrameGetObjByName($frame,"Logout")
If $oButton == 0 Then
MsgBox(0, "Test", "Error")
Else
MsgBox(0, "Test", "Good")
EndIf

and I received MsgBox - "Success - you have frame handle", but after that nothing more. I didn't receive next MsgBox ("Error" or "Good"). Maybe I use _IEFrameGetObjByName incorrectly? This is really strange for me because on other pages I don't have any problems with getting handle to elements.

Link to comment
Share on other sites

Ok I figured it out that I should use _IEFrameGetObjByName in other way:

$frame = _IEFrameGetObjByName($oIE,"topFrame")
If $frame == 0 Then
MsgBox(0, "Test", "Error")
Else
MsgBox(0, "Test", "Success - you have frame handle")
EndIf
$oButton = _IEFormImageClick($frame,"Logout","name")
If $oButton == 0 Then
MsgBox(0, "Test", "Error")
Else
MsgBox(0, "Test", "good")
EndIf

When I use this code I don't receive any MsgBox, I don't know why, but I am sure that this is problem with frames. I will appreciate it if anyone give me some advice.

Edited by daro
Link to comment
Share on other sites

Yes I am using sciTE but till now I haven't known that I can observe the result of the _IE functions. I will read about it. I tried to use _IEFormImageClick and I saw this error:

==> The requested action with this object has failed.:
If String($o_object.document.body.tagName) = "FRAMESET" Then
If String($o_object.document^ ERROR

Maybe I haven't seen it before, I am not sure, but I don't know what this error mean.

In the meantime, I found similar problem on the forum under this link: '?do=embed' frameborder='0' data-embedContent>>
I tried this code:

$oIE=_IECreate("web")
$oDoc = _IEDocGetObj($oIE)
MsgBox(0,"","")
$oArray = $oDoc.getElementsByTagName("Frame")
for $element in $oArray
    MsgBox(0,"",$element.name)
next

and it works properly, the script recognizes the frames. But I don't know how to get "logout" bottom from the frame "topFrame". Do you have any ideas?

Thanks for your help so far.

Link to comment
Share on other sites

I am trying to automate testing procedure on the webpage of the company where I work. Currently I am using image recognitioning to navigate the page but I would like to do this in universal way by using _IE functions.

I have access denied errors when I run my script in sciTE.:

----> $IEComErrorWinDescription = Access is denied.
----> $IEComErrorDescription = Access is denied.

In this topic: '?do=embed' frameborder='0' data-embedContent>> I found out that this is because of IE cross-domain scripting security as @DaleHohm wrote there.

I will try what he advises there:

 

Access is denied. indicates that you are running into a security issue enforced by IE whereby you cannot gain access to a frame whose source is in another domain. You'll need to open the frame in a new window with _IECreate. Search for cross-domain security.

and I will write here the result.

Link to comment
Share on other sites

Ok I have good news, When I opened the frame in a new window with _IECreate then I had access to the "logout" bottom. I will try to change an IE setting which could help me to get access to frames as soon as I receive admin access.

 

IT is : Tools > Internet Options > Security > Local Intranet. Click Sites.

Thanks for help so far :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...