automate a website with frame, cannot print the whole page?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
bbgaw
Newbie
Posts: 13
Joined: Thu May 08, 2008 7:54 pm

automate a website with frame, cannot print the whole page?

Post by bbgaw » Tue May 13, 2008 7:19 pm

Hi, Dear All,

I am trying to automate this webpage. but it seems like there are two parts on this page. I can always print the top part, but I really need to print all of them. Especially when I need to click a box in the bottom part to proceed.
Is there anyway to handle this type webpage?
Thanks in advance!

Here is my scripts:

IE_Navigate>%IE[0]%,http://www.safe.nite.go.jp/english/db.html,r
IE_Wait>%IE[0]%,r
Wait>delay

Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"Image10"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,IMG,NAME,str:TagValue,r

IE_Wait>%IE[0]%,r
Wait>delay

Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"http://www.safe.nite.go.jp/english/img_ ... arch_e.gif"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,IMG,HREF,str:TagValue,r

IE_Wait>%IE[0]%,r
Wait>delay

Let>FrameName={"frm_main"}
Let>FormName={"[object]"}
Let>FieldName={"num"}
Let>FieldValue={"71-43-2"}
IE_FormFill>%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r

Let>FrameName={"frm_main"}
Let>FormName={"selectform"}
Let>TagValue={"search"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r

IE_Wait>%IE[0]%,r
Wait>delay

Wait>3

IE_ContainsText>IE[0],,No substance,exists1

IF>{(%exists1%=0)}

Let>FrameName={"frm_main"}
Let>FormName={"selectform"}
Let>TagValue={"[1]"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,A,TEXT,str:TagValue,r

IE_Wait>%IE[0]%,r
Wait>delay

Wait>5

ENDIF

Wait>5

SetFocus>Total *
Wait>2

//press CTRL+P to invoke print dialog
Press CTRL
Send>p
Release CTRL

//wait for print dialog to appear
WaitWindowOpen>Print
Wait>1

//Select PDFCreator option
Send>PDFCreator
Press Enter

//Wait for PDFCreator window
WaitWindowOpen>PDFCreator 0.*
Wait>1
Press Enter

//wait for Save As dialog to appear
WaitWindowOpen>Save as

//send the filename (value from input file)
Send>%folder%%line%

//press Save
Press ALT
Send>s
Release ALT

WaitWindowClosed>Save as
WaitWindowClosed>PDF Creator*

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu May 15, 2008 7:35 am

IE think will print whichever is the focused frame. So you probably need to click in the main frame. However, personally, I'd take the frames out of the equation. Navigate directly to the frame you want to work with:

Code: Select all

IE_Create>0,IE[0]

IE_Navigate>%IE[0]%,http://www.safe.nite.go.jp/kouzou/cgi-bin/input_e.cgi,r
IE_Wait>%IE[0]%,r
Wait>delay

Let>FrameName={""}
Let>FormName={"[object]"}
Let>FieldName={"num"}
Let>FieldValue={"71-43-2"}
IE_FormFill>%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r

Let>FrameName={""}
Let>FormName={"selectform"}
Let>TagValue={"search"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r

IE_Wait>%IE[0]%,r
Wait>delay

Wait>3

IE_ContainsText>IE[0],,No substance,exists1

IF>{(%exists1%=0)}
Let>FrameName={""}
Let>FormName={"selectform"}
Let>TagValue={"[1]"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,A,TEXT,str:TagValue,r

IE_Wait>%IE[0]%,r
Wait>delay

Wait>5
ENDIF

Wait>5

SetFocus>Total *
Wait>2

//press CTRL+P to invoke print dialog
Press CTRL
Send>p
Release CTRL

//wait for print dialog to appear
WaitWindowOpen>Print
Wait>1

//Select PDFCreator option
Send>PDFCreator
Press Enter

//Wait for PDFCreator window
WaitWindowOpen>PDFCreator 0.*
Wait>1
Press Enter

//wait for Save As dialog to appear
WaitWindowOpen>Save as

//send the filename (value from input file)
Send>%folder%%line%

//press Save
Press ALT
Send>s
Release ALT

WaitWindowClosed>Save as
WaitWindowClosed>PDF Creator*
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

bbgaw
Newbie
Posts: 13
Joined: Thu May 08, 2008 7:54 pm

more questions

Post by bbgaw » Mon Jun 02, 2008 1:22 pm

Hi, Marcus!

This method works and I am able to search this webpage and save resutls!

I wonder how you find out the following frame to navigate in this example.

IE_Navigate>%IE[0]%,http://www.safe.nite.go.jp/kouzou/cgi-bin/input_e.cgi

Currently I met another similar problem, but differ a little bit.

I try to search this webpage:
http://www.safe.nite.go.jp/data/hazprtr ... put_object

It looks to me that it has just one frame. After I input query item (71-43-2) and click search, then I feel I got two frames. I need to click the bottom frame to proceed. But I don't know how to focus on it. Could you please help me with this?

Thanks a lot! and here is my code which again, only print the top part of results.

IE_Navigate>%IE[0]%,http://www.safe.nite.go.jp/data/hazprtr ... t_object,r
IE_Wait>%IE[0]%,r
Wait>delay

Let>FrameName={""}
Let>FormName={""}
Let>FieldName={"cas_no"}
Let>FieldValue={"71-43-2"}
IE_FormFill>%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0,r

Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"sub1"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r

IE_Wait>%IE[0]%,r
Wait>delay

Wait>2

IE_ContainsText>IE[0],,No Substances,exists1

IF>{(%exists1%=0)}
Let>FrameName={"frame2"}
Let>FormName={""}
Let>TagValue={"d_selnum"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue,r

IE_Wait>%IE[0]%,r
Wait>delay

ENDIF

Wait>4

//press CTRL+P to invoke print dialog
Press CTRL
Send>p
Release CTRL

//wait for print dialog to appear
WaitWindowOpen>Print
Wait>1

//Select PDFCreator option
Send>PDFCreator
Press Enter

//Wait for PDFCreator window
WaitWindowOpen>PDFCreator 0.*
Wait>1
Press Enter

//wait for Save As dialog to appear
WaitWindowOpen>Save as

//send the filename (value from input file)
Let>folder=c:\MacroCAS\%line%\
Send>%folder%%line%_PRTR

//press Save
Press ALT
Send>s
Release ALT

WaitWindowClosed>Save as
WaitWindowClosed>PDF Creator*

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts