| 
		
	
	
	
		
	Posts: 166Threads: 57
 Joined: Aug 2013
 
	
	
		Greetings, 
Kindly advise on how to use a if...else condition on checking for 2 web pages. 
Depending on the previous web page, 1of the 2 web page comes through. 
This is how I manage as of now: 
Macro RO Sales gDN ,int w3=wait(10 WC win("Question Time! - Windows Internet Explorer" "IEFrame")),Htm e50=htm("INPUT" "rbnTrue1" "" w3 "0" 3 0x121 3)
 ,err+
 ,,goto ncontinue
 ,e50.Click
 ,
 ,wait 0.25
 ,Htm e22=htm("INPUT" "btnSubmit" "" w3 "0" 5 0x121 3)
 ,e22.Click
 ,
 ,;ncontinue
 ,int w5=wait(100 WC win("select_product - Windows Internet Explorer" "IEFrame"))
 ,Htm e18=htm("INPUT" "btnNext" "" w5 "0" 15 0x121 3)
 ,e18.Click
Best Regards,Philip
 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		If your macro works, and you just want to replace err goto to if: 
Macro Macro2333 ,Htm e50=0,int w3=wait(10 WC win("Question Time! - Windows Internet Explorer" "IEFrame"))
 ,if(w3) e50=htm("INPUT" "rbnTrue1" "" w3 "0" 3 0x101 3) ;;note: removed flag 32 (error if not found)
 ,if e50
 ,,e50.Click
 ,,
 ,,wait 0.25
 ,,Htm e22=htm("INPUT" "btnSubmit" "" w3 "0" 5 0x121 3)
 ,,e22.Click
 ,
 ,int w5=wait(100 WC win("select_product - Windows Internet Explorer" "IEFrame"))
 ,Htm e18=htm("INPUT" "btnNext" "" w5 "0" 15 0x121 3)
 ,e18.Click
 ,
 
	
	
	
		
	Posts: 166Threads: 57
 Joined: Aug 2013
 
	
	
		Hi Gintaras,
 Yes, I need to do away with goto and err.
 
 I tried your code.
 However, I need the if to check whether the new web page is w3 or w5.
 if w3 then execute e50 & e22
 elseif w5 then execute e18.
 
 Could you re-advise me on this.
 
 Thanks,
 Philip
 
Best Regards,Philip
 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		try this 
Macro Macro2333 ,int w3=win("Internet Explorer" "IEFrame"),str s.getwintext(w3)
 ,sel s 2
 ,,case "Question Time! -*"
 ,,Htm e50=htm("INPUT" "rbnTrue1" "" w3 "0" 3 0x121 3)
 ,,e50.Click
 ,,wait 0.25
 ,,Htm e22=htm("INPUT" "btnSubmit" "" w3 "0" 5 0x121 3)
 ,,e22.Click
 ,,
 ,,case "select_product -*"
 ,,Htm e18=htm("INPUT" "btnNext" "" w3 "0" 15 0x121 3)
 ,,e18.Click
 
	
	
	
		
	Posts: 166Threads: 57
 Joined: Aug 2013
 
	
	
		Tried but QM seems to jump to the next line after sel group of codes (i.e., to w6). 
I have added the codes before and after the codes in question for you reference. 
Does the codes after each case need to be intended further...
 
Macro RO Sales gDN ,;;Click Next,Htm e15=htm("INPUT" "_ctl0_cphMain_btnNext" "" w4 "0" 55 0x121 3)
 ,e15.Click
 ,
 ,wait 3
 ,int w3=win("Internet Explorer" "IEFrame")
 ,str s.getwintext(w3)
 ,sel s 2
 ,,case "Question Time! -*"
 ,,Htm e50=htm("INPUT" "rbnTrue1" "" w3 "0" 3 0x121 3)
 ,,e50.Click
 ,,wait 0.25
 ,,Htm e22=htm("INPUT" "btnSubmit" "" w3 "0" 5 0x121 3)
 ,,e22.Click
 ,,
 ,,case "select_product -*"
 ,,Htm e18=htm("INPUT" "btnNext" "" w3 "0" 15 0x121 3)
 ,,e18.Click
 ,
 ,;wait 30 WT w4 "view_policy_details - Windows Internet Explorer"
 ,int w6=wait(30 WC win("view_policy_details - Windows Internet Explorer" "IEFrame"))
Best Regards,Philip
 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		Indentation is correct. To see what is browser window name, after the getwintext line insert line,out s
 If name does not begin with "Question Time! -" or "select_product -", need to change something.
 Or run the macro in debug mode. In QM press F5, F5, F5...
 
	
	
	
		
	Posts: 166Threads: 57
 Joined: Aug 2013
 
	
	
		Yes, you were right.The web page uses the name "Client Details -*"
 However it uses "Client Details -*" for both "Question Time" and "select_product"
 But the name shown on the web page title bar is "Question Time" and "select_product"
 How would QM differentiate...
 I guess now the logic should be 'with same page...'
 if e50 then e50.click and e22.click
 else e18.click
 
 Am I right?
 
Best Regards,Philip
 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		Macro Macro2333 ,int w3=win("Internet Explorer" "IEFrame"),Htm e50=htm("INPUT" "rbnTrue1" "" w3 "0" 3 0x101)
 ,if e50 ;;page "Question Time! -*"
 ,,e50.Click
 ,,wait 0.25
 ,,Htm e22=htm("INPUT" "btnSubmit" "" w3 "0" 5 0x121 3)
 ,,e22.Click
 ,else
 ,,Htm e18=htm("INPUT" "btnNext" "" w3 "0" 15 0x101)
 ,,if e18 ;;page "select_product -*"
 ,,,e18.Click
 ,,else
 ,,,mes "error"
this also waits, max 5 s 
Macro Macro2333 ,int found=0,int w3=win("Internet Explorer" "IEFrame")
 ,rep 10
 ,,Htm e50=htm("INPUT" "rbnTrue1" "" w3 "0" 3 0x101)
 ,,if e50 ;;page "Question Time! -*"
 ,,,e50.Click
 ,,,wait 0.25
 ,,,Htm e22=htm("INPUT" "btnSubmit" "" w3 "0" 5 0x121 3)
 ,,,e22.Click
 ,,,found=1; break
 ,,else
 ,,,Htm e18=htm("INPUT" "btnNext" "" w3 "0" 15 0x101)
 ,,,if e18 ;;page "select_product -*"
 ,,,,e18.Click
 ,,,,found=2; break
 ,,,else
 ,,,,0.5
 ,if(!found) mes "error"
 
	
	
	
		
	Posts: 166Threads: 57
 Joined: Aug 2013
 
	
	
		Object not found error at Htm e50=... lineMost of the time it is e18 if w3 explorer title is "select_product" but could be e50+e22 if w3 explorere title is "Question Time"
 However, w3 is always "Client Details"
 
Best Regards,Philip
 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		I forgot to remove flag 32 - error if not found. Replace both 0x121 to 0x101.
	 
	
	
	
		
	Posts: 166Threads: 57
 Joined: Aug 2013
 
	
	
		Works like a breeze.Thanks.
 
 Could you explain why the rep 10 is used here...
 
Best Regards,Philip
 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		To wait if not found immediately. Use code without rep if don't need to wait.
	 |