Be careful while using SystemUtil.Run method

2
75
Spread the love
  • 11
  • 12
  • 24
  • 10
  •  
  •  
  •  
  •  
  •  
  •  
    57
    Shares

Be watchful while utilizing SystemUtil.Run technique

This post also talks about how to open an URL.
For projects, Tester by and large uses SystemUtil – an inbuilt object of QTP/UFT-to dispatch the application.The miserable piece of this strategy is that it can not separate among explorer and iexplorer.Accordingly, we by and large get the beneath composed Error tossed from QTP/UFT.

“Can’t recognize the article parent. Ensure that… … ”

I kept an eye on program bar uncovered that it was being perceived as a window rather than the program! Some more R and D and It was found that the issue lies with the SystemUtil.Run strategy. I was utilizing

SystemUtil.Run “explorer” url When I changed that to

SystemUtil.Run “iexplore”, [url] content began running fine. I surmise while utilizing wayfarer, QTP/UFT anticipates a record way and not a HTTP way on it.To dispatch an application, I figure a superior option is make a shell item and dispatch applications utilizing its Run strategy. It will take around 4 lines of code. (counting revelation and decimation of shell object)

It is prescribed that as opposed to utilizing System. Util .or run technique. It is smarter to utilize the “cmd” that is the order arrange (straightforward dos)Type way through QTP/UFT and run the document u want.This is the most solid methodology.

What are the best Way to Invoke Applications in UFT/QTP?

VBscript to summon application .Make a “WScript.shell” object. Utilize the “run” method to dispatch the application. In the event that the way to your executable contains spaces, use Chr(34) to guarantee the way is contained inside double quote.Whenever done, set the shell item to nothing to discharge it.


Model:
Dimi oMyShell
Set oMyShell= CreateObject ("Wscript.shell")
'Model 1 - run a group record:
oMyShell.run "<<pathof the bat file>>.bat"
'Model 2 - run a Java container document(jar):
oMyShell.run "java - jar <<path of jar>>.jar"
'Model 3 - dispatch Internet Explorer:
oMyShell.Run Chr(34) and "C://Program Files/Internet Explorer/IEXPLORE.EXE" and Chr(34)
'Model 4 - dispatch Firefox:
oMyShell.Run Chr(34) and "C://Program Files/Firefox/Firefox.exe" and Chr(34)
'Model 4 - dispatch Notepad:
oMyShell.Run Chr(34) and "<<path of notepad>>Notepad.exe" and Chr(34)
Set oMyShell= Nothing
 

Read also here for 6 different types of invoking methods.

This is very important for framework developer to make a generic function to open an application.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 11
  • 12
  • 24
  • 10
  •  
  •  
  •  
  •  
  •  
  •  
    57
    Shares

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here