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!



11 comments ↓
how we work with shell object sin QTP?
Could you give us an example of the new code ?
How to test web applications using 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 use web aplications in QTP…………………..?
‘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“)
you can use this,
Set oIE = CreateObject(“InternetExplorer.Application”)
oIE.visible = 1
oIE.Navigate2 URL
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.”
@ 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.
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
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
Leave a Comment