For one of my projects, I was using SystemUtil -an inbuilt object of QTP- to launch my application. For about 5 times script-replay was perfect, the 6th times onwards QTP started throwing an error:
Cannot identify the object parent. Make sure that……
Object spy on browser bar revealed that it was being recognized as window instead of browser! Some more R & D and I discovered that the problem lies with the SystemUtil.Run method. I was using SystemUtil.Run “explorer”, <URL>. When I changed that to SystemUtil.Run “iexplore”, <URL> script started running fine. I guess while using explorer, QTP expects a file path and not a HTTP path on it. Having said that, I am still not sure how it ran fine for the first few times.
To launch an application, I think a better alternative would be to create a shell object and launch applications using its Run method. It will take about 4 lines of code.(including declaration and destruction of shell object)
Probably a good time to change my habit of writing the shortest possible code while programming!
Hi ankur. I am trying to launch 2 firefox instances using SystemUtil.run method as below.
SystemUtil.run “firefoxe.exe”,”www.google.com”
SystemUtil.run “firefoxe.exe”,”www.gmail.com
This method is launching only the first instance “google.com” and the second statement is getting skipped. why is this weired behavior ?
“explorer” is a window and “iexplore” is a browser. I don’t believe QTP is acting any weird here.
Moreover, browsers are not designed to handle filepaths unless you are opening one of those file extensions that browsers understand. HTML for example. A browser can handle pretty much anything web related including ftp. On the other hand, explorer handles OS level operations like browsing through directory structure or a network etc.
@JustAPoint: Thanks for your comments. Paul has given a good explanation in the comments below.
Plz tell me how to open chrome and firefox browser using qtp 10?
also tell me which version of chrome /firefox is required????
URL = Environment(“BrowserLink”)
Set InvokeApp = CreateObject(“WScript.Shell”)
InvokeApp.Run(“iexplore &(“BrowserLink”)&”) — This is what i did to incorporate an env variable that contains the browser link, but desn t work. can someone help pls
how to use SystemUtil.Run to open Google Chrome browser
Hi Ankur
Could you please let me know the difference between
CreateObject(“InternetExplorer.Application”) and
systemutil.Run”Iexplore.exe”
Both will launch IE only then what is the difference
Could you please elaborate it n explain me
Actually, I ran into the same problem but made my code SHORTER and it fixed it.
Usually this works:
SystemUtil.Run “C:\Program Files\Internet Explorer\IEXPLORE.EXE”,gURL,””,”open”
but at another website it did not. So I changed it to this and now it always works:
SystemUtil.Run gURL
How to get the url of the website from the address bar…
Suppose there is a url http://www.abc.com/default
After u click on a link it should navigate to another link- http://www.abc.com/insight.aspx
So how to know whether the page has navigated to http://www.abc.com/insight.aspx, after I click on a link.
Please reply with solution…
Thank you
@ Ankur….. You wrote- “I am still not sure how it ran fine for the first few times.”
After the Windows 98 version, all versions treat windows explorer the same way as the internet explorer and vice versa.
You can open windows explorer and type http://www.xyz.com in place of say, C:\xyz and it will open xyz on internet explorer. Similarly you can open internet explorer and type C:\xyz in address bar and it will open that directory.
It’s a Windows thing. Somewhere between the 5th and 6th time, you opened an Explorer window and “browsed” to a local file folder instead of a URL. Windows notes that the last time explorer.exe was open it was as a folder structure window.
Now Explorer expects to browse to the file system and displays a window by default, and QTP is looking for a Browser. But at the last (mili)second Windows pulls a fast one and says “Hey, this is a URL!” and switches the window to a browser.
QTP then says “Hey Moe! There’s no browser here, all that’s popped up so far is this Window. Nyuk, nyuk, nyuk.”
you can use this,
Set oIE = CreateObject(“InternetExplorer.Application”)
oIE.visible = 1
oIE.Navigate2 URL
‘Hey…
This scrip will helpful to you. You can initiate either if the window or browser object using this.
Set abc = CreateObject(“WScript.Shell”)
abc.Run(“iexplore http://yahoo.com“)
How to use web aplications in QTP…………………..?
how to create a function with variable number of arguments? That is, at one instant i will pass only one argument to the function and other i may pass two or more arguments
How to test web applications using QTP?
Could you give us an example of the new code ?
how we work with shell object sin QTP?