Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using DP to define windows
#1
Not Solved
I am new only 4 weeks into QTP. I have scripts that only use a 2 items in a repository.
They are:

Code:
Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Type "This is a test"

The Window & WinObject objects. I use these so that I can insert randowm strings into ajax grids, copy them and do STRCompare.
I would like to use the Description.Create method I have used for all other objects I get ROProperties on. However What I have written fails.

Code:
Set IEwindow = Nothing
Set IEwindow = Description.Create
IEwindow("regexpwndclass").Value = ObjWindow
'=====
Set ObjWin = Nothing
Set ObjWin = Description.Create
IEwindow("regexpwndclass").Value = WinObj
'=====
ObjWindow = Window(IEwindow).GetROProperty("regexpwndclass")
WinObj = Window(IEwindow).WinObject(WinObj).GetROProperty("regexpwndclass")

Every other object that I have to identify in the script uses this approach and works correctly.

Am I a dummy or is there something I have failed to see?
Suggestions welcomed Smile

mrerek
Reply
#2
Not Solved
assignment to variable after its usage??

shouldn't it be,

Code:
ObjWindow = Window(IEwindow).GetROProperty("regexpwndclass")
WinObj = Window(IEwindow).WinObject(WinObj).GetROProperty("regexpwndclass")

Set IEwindow = Nothing
Set IEwindow = Description.Create
IEwindow("regexpwndclass").Value = ObjWindow
'=====
Set ObjWin = Nothing
Set ObjWin = Description.Create
IEwindow("regexpwndclass").Value = WinObj

by the way your web addin doenst seem to be loaded, it should show "browser" instead of window in my opinion
Reply
#3
Not Solved
Thank you rajpes for your reply.

I think I need to clarify further.
I use the followong code to define and set The Browser and Page Objects for my test as the first few lines for my test.

Code:
' Browser Description ====================
    Set ObjBrw = Nothing
    Set ObjBrw = Description.Create
    ObjBrw("name").Value = BrwHandle
'Page Description ====================
    Set objPge = Nothing
    Set ObjPge = Description.Create()
    ObjPge("title").value = PgeHandle
BrwHandle = Browser(ObjBrw).GetROProperty("name")
PgeHandle = Browser(ObjBrw).Page(ObjPge).GetROProperty("title")

If I move the last 2 lines ABOVE the Browser and Page Descriptions QTP displays an "unknown" error stepping thru the begining of the script.

If I leave the 2 lines where BELOW the descriptions [as written above] the 2 variables are correctly identified and everything in the scripts runs fine.

I use a single object repository that contains 2 objects [ Windows Internet Explorer & Internet Explorer_Server ] I captured using a low level recording.
This enables me to type random strings I generate into ajax grids on the page. This all works fine for 10 actions in the test.

What I am attempting to do is remove my dependence on the small repository that I am using to type random strings.
I wish to make the code transportable through a rather large set of modules within the application.
My initial thought was that if I followed what I have been using successfully I could do the same for these other two objects.
Hence I came up with the code I originally posted. I do have my web add-in loaded.

Does this clarify things - suggestion[s]?

Thank you - mrerek
Reply
#4
Not Solved
How will that generate random strings? what logic do you think qtp will use to generate random string?
Reply
#5
Not Solved
More clarification is needed...
This is what I use to create the randoms strings...

Code:
Const LETTERS =  "abcdefgh ijklmnopqrstuvwxyz ABCDEFGH IJKLMNOPQRSTUVWXYZ 0123456 789 ~!#$%^*()_+-=/?,<.>"

For i = 1 to RowCount
    Dim str
    For x = 1 to MaxCharCount
        str = str & Mid (LETTERS, RandomNumber(1, Len(LETTERS)), 1)
    Next
        [b]Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Type[/b] str
        Browser(ObjBrw).Sync
        [b]Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Type [/b]micDwn
        str = ""
Next

So I utilize the
Code:
Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Type


to type in the str
The RowCount & MaxCharCount are calculated elsewhere

My intention is to use Descriptive Programming to create the
Window("Windows Internet Explorer").WinObject("Internet Explorer_Server")
objects so I can use them to type in my strings but NOT have to have them in a repository.

These are the only 2 objects I have in a repository and I would like to not have to rely on them to make the code in the script[s] truly transportable through multiple modules in the app I am testing.

Does this clarify things?
I am open to suggestions.
Thanks, rajpes
Reply
#6
Not Solved
Code:
ObjBrw("name").Value = BrwHandle
BrwHandle = Browser(ObjBrw).GetROProperty("name")
it's like a deadlock.


As long as i know name,title,regexpwndclass property values will stay unique for a page.If so, you can make descriptive programming directly as

Code:
browser("title:=titile_property_shown_in_object_spy").page("title:=titile_property_shown_in_object_spy"").Sync

It doesnt seem like browser and page objects are identified by your qtp , make sure web add-in is loaded!
Reply
#7
Not Solved
I have come up with the following strategy using SendKeys.

Code:
Dim [b]str[/b]= ""
For i = 1 to RowCount
    For x = 1 to MaxCharCount
      [b]str[/b] = str & Mid (LETTERS, RandomNumber(1, Len(LETTERS)), 1)
    Next
      Set KeyShell = CreateObject("WScript.Shell")
      KeyShell.SendKeys [b]str[/b]    KeyShell.SendKeys ("{DOWN}")
      str = ""
Next

However QTP tells me that I have passed a bad parameter to SendKeys.

I am looking for a suggestion to pass the variable str to SendKeys 20 times to populate a cell grid
with 1200 characters.
Thanks - mrerek
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What are different types of Function we define in UFT? amit25007 1 3,093 03-09-2016, 09:08 PM
Last Post: supputuri

Forum Jump:


Users browsing this thread: 1 Guest(s)