Forum Discussion
14 years ago
Hi All..
I am not sure if you already know the below solution, but thought of posting this since I am not able to search the following method in this forum.
Dont know how far the following code will help you, but i am sure, this will give you an outline how i managed to select an item from a DBGrid (whose object props/methods are not accessible).
'TestComplete Version 8.20.538.7
.....
.....
set rect = YourAppName.TcxComboBoxPopupWindow.TcxCustomLookupDBGrid.Picture
set OCRObj = OCR.CreateObject(rect)
set OCROptions=OCRObj.CreateOptions
OCROptions.ActiveRecognitionSet=2 '2 will recognize chars as upper case A-Z
a=OCRObj.GetText
b=OCRObj.FindRectByText("REQUIRED MENU", OCROptions) 'If not recognized, by default TC throws error here and stops execution
x=OCRObj.FoundX
y=OCRObj.FoundY
Call YourAppName.TcxComboBoxPopupWindow.TcxCustomLookupDBGrid.Click(x,y)
Limitations:
1. I am using OCR method. There is one limitation using this method. Os in "TOOLS" can be detected as zeroes ("T00LS"), which leads to false.
ActiveRecognitionSet is the key here.
(My application had only upper case A-Z chars in dropdown list, so i used ActiveRecognitionSet=2.
I tried adding a menu "AO1" A-zero-one and the above method failed by recognizing text as "A01" A-oh-one)
2. If the menu item which you want is already in selected mode (highlighted), then this method is failing for me. Of course, works fine when no item is selected/highlighted.
3. To handle error, uncheck the option Current Project Properties -> Playback -> Stop on error -> uncheck this option. Then you can use On Error Resume Next and On Error GoTo 0 as required in your script.
Please feel free to share your feedback or enhanced version of the above.
Thanks.
I am not sure if you already know the below solution, but thought of posting this since I am not able to search the following method in this forum.
Dont know how far the following code will help you, but i am sure, this will give you an outline how i managed to select an item from a DBGrid (whose object props/methods are not accessible).
'TestComplete Version 8.20.538.7
.....
.....
set rect = YourAppName.TcxComboBoxPopupWindow.TcxCustomLookupDBGrid.Picture
set OCRObj = OCR.CreateObject(rect)
set OCROptions=OCRObj.CreateOptions
OCROptions.ActiveRecognitionSet=2 '2 will recognize chars as upper case A-Z
a=OCRObj.GetText
b=OCRObj.FindRectByText("REQUIRED MENU", OCROptions) 'If not recognized, by default TC throws error here and stops execution
x=OCRObj.FoundX
y=OCRObj.FoundY
Call YourAppName.TcxComboBoxPopupWindow.TcxCustomLookupDBGrid.Click(x,y)
Limitations:
1. I am using OCR method. There is one limitation using this method. Os in "TOOLS" can be detected as zeroes ("T00LS"), which leads to false.
ActiveRecognitionSet is the key here.
(My application had only upper case A-Z chars in dropdown list, so i used ActiveRecognitionSet=2.
I tried adding a menu "AO1" A-zero-one and the above method failed by recognizing text as "A01" A-oh-one)
2. If the menu item which you want is already in selected mode (highlighted), then this method is failing for me. Of course, works fine when no item is selected/highlighted.
3. To handle error, uncheck the option Current Project Properties -> Playback -> Stop on error -> uncheck this option. Then you can use On Error Resume Next and On Error GoTo 0 as required in your script.
Please feel free to share your feedback or enhanced version of the above.
Thanks.