Sign in to follow this  
Followers 0
JLogan3o13

Unable to isolate and click on object in IE

12 posts in this topic

I am looking into automating running a report in Business Objects. It is basically a web page, which has single sign on so no need to automate the login. I am having some trouble getting it to click on the button or link, I think because of all the javascript. I have tried a couple of different methods, such as getting the object by name, id, innertext, etc. Can anyone offer some suggestions, or tell me if this is simply going to resist all attempts at automation? Any suggestions are appreciated (even if it is that I am SOL) :)

 

I can see there is the one Frame, and can see the innertext, but unsure how to click on the one button.

#include <IE.au3>

$oIE = _IEAttach("SAP BusinessObjects")
Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
For $i = 0 To ($iNumFrames - 1)
    Local $oFrame = _IEFrameGetCollection($oIE, $i)
    MsgBox(0, "Frame Info", _IEPropertyGet($oFrame, "innertext"))
Next

My goal is to hit either the button at the top or the link next to the image:

post-54985-0-73579800-1371220292_thumb.p

And this is the source

BO.txt


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I would think either of these would work for you

#include <IE.au3>

$oIE = _IEAttach("SAP BusinessObjects")
$oIE.document.parentWindow.execScript('showDocumentList();',"javascript")
#include <IE.au3>

$oIE = _IEAttach("SAP BusinessObjects")
_IELinkClickByText($oIE, "Document List")

Of course, I am giving a best guess here since I don't have the css or javascript files that this page uses.

Edited by danwilli

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Oh snap, danwilli beat me to it, and even provided a way to call it internally.  :) 

----
 
If the layout of the page doesn't change, you can maximize the window and hardcode x,y co-ordinates for a mouse click.  (If you play with Zoom features, you'll want to make sure that that's constant too.)
 
You can use various Pixel functions (PixelChecksum might be best) to find the document list icon/text and click that.
 
There may be a way to parse the HTML file itself, extract the JS function it will call (showDocumentList), and cause the browser to call that JS function.
 
It's hard to be more helpful right now, as I don't have any images or CSS to work with.  The plain HTML file looks quite different from the attached screenshot.

Edited by Artisan

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Just a tip for looping objects:

Local $oFrames = _IEFrameGetCollection($oIE)
For $oFrame in $oFrames
    MsgBox(0, "Frame Info", _IEPropertyGet($oFrame, "innertext"))
Next
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

@danwilli - Thanks for the suggestion. I forgot to mention in my OP that I had tried the clicklinkbytext, but it doesn't do the job. I tried your first suggestion (didn't even know I could call the javascript function like that) but it returns the old "requested action with this object has failed error". I'm going to try playing around with it more.

@Artisan - I thought about that, but the end goal is for the window not to be visible to the user, which limits my options on simulating a click on the page. Plus, based on past experience, I like to stay away from MouseClick whenever possible. Thanks for the suggestions though.

@jldelaney - Thanks, the one I used I just stole from the help file. This is all linked to my other post regarding the Oracle db; trying to come up with a quick and dirty if I am unable to format the sql calls correctly :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@danwilli - Thanks for the suggestion. I forgot to mention in my OP that I had tried the clicklinkbytext, but it doesn't do the job. I tried your first suggestion (didn't even know I could call the javascript function like that) but it returns the old "requested action with this object has failed error". I'm going to try playing around with it more.

Hmm, testing with the html provided, both work fine.

Can you provide the javascript and css file?

Or better yet, will you just save the page as mht in IE and upload it?

Edited by danwilli

Share this post


Link to post
Share on other sites

Use a spy tool, and grab the html for the specific object you are attempting to click.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

I did use the IE Dev Toolbar, and get an ID of the object (IconImg_Txt_btnListing), but still cannot select it.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

There must be a proper way to do this with just IE.au3 but I'm having little luck, and the mht isn't nearly as complete as I had hoped it would be.

Does this error on you?

#include <IE.au3>

$oIE = _IEAttach("SAP BusinessObjects")
$oIE.document.parentWindow.execScript('var hplus = getHeaderPlusFrame();if (hplus) {hplus.onBtnListingClick();}',"javascript")
1 person likes this

Share this post


Link to post
Share on other sites

That works! Wow, what a bugger of a page. Thanks danwilli. I can see now how you called the javascript function - will try that out on the other items I need to click.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Sorry to bring this back from the dead but....I got the code to work and click the documents list....I am not sure exactly what is happening but it opens it.

Next I need to choose My Favorites but not sure what to do from there

I am assuming JLogan got it to work but just can't follow what happened

edit:

I got it to work well...1 step further

$oIE.document.parentWindow.execScript('var faveID = "15624042";if (faveID != "") {showInWorkspace("../../InfoViewApp/listing/objectList.do?objId=" + faveID);}',"javascript")

now I just can't figure out how to open the report...I see it though which is a step in the right direction

Edited by Kurto2021

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