Thursday, July 9, 2015

Miscelleneous

- Option Explicit

- Loops:
1. For Loop
2. Do While Loop
3. While Wend  ---Wend - while end

- Array
UBound(), LBound()

- String Functions:

1. TRIM()
2. RTRIM()
3. LTRIM()
4. LEN()
5. MID()
6. INSTR()   -returns position

7. SPLIT()


 - .Exist

Is used to find whether objects exists or not.

- .value

Without mentioning the .value method, we can use GetROProperty to retreive value of the property of object.
 - If you do not want to use Browser and Page all the time, create object and use it when ever needed, instead.

Set obj = Browser("<name>").Page("<name>")

obj.WebEdit("c").set = "a"

- Syntax checker -- Is small utility in menu bar, is used to find the syntax of your script.

Go to Design->Check Syntax

- Understand the methods: Select  the method and click on F1, it will direct you the description of the method.

- SystemUtil.Run

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.

- RunAction  -------
Runs a specific action from the open test and creates results in the specified file or ALM path.
Syntax –
object.RunAction Name, [ResultsOptions], [WaitOnReturn], [Parameters]

Issues:

- Can we have the code:  Half of the statement with descriptive programming another half with Object Respository? ---- Not Solved
- In most of the scenarios I have worked with, script worked when I stored Objects in OR and started the script, but when I do descriptive programming the same script fails.
And another issue is script is not consistent, it will work in first run and fails in second run. --- Not Solved.


Code:

-  Not sure how the function got called here??? --- Not Solved


Function GetHoverColor(oLink)
    Setting.WebPackage("ReplayType") = 2
        oLink.FireEvent "onMouseOver"
        GetHoverColor = oLink.Object.currentStyle.color
    Setting.WebPackage("ReplayType") = 1
End Function
 
RegisterUserFunc "Link", "GetHoverColor", "GetHoverColor"
Now, whenever the link color is to be retrieved, you can simply call the “GetHoverColor” function as you would normally use the Click event:
MsgBox Browser("Browser").Page("Page").Link("Link").GetHoverColor
 -  Whole code looks different:   ????? -- Not Solved

Sub My_MouseOver(objSender) //how objSender variable is passed
    Dim absX : absX = objSender.GetROProperty("abs_x")
    Dim absY : absY = objSender.GetROProperty("abs_y")
    Dim width : width = objSender.GetROProperty("width")
    Dim height : height = objSender.GetROProperty("height")
    Dim x : x = (absX + (width / 2))
    Dim y : y = (absY + (height / 2))
    Dim deviceReplay : Set deviceReplay = CreateObject("Mercury.DeviceReplay")
    deviceReplay.MouseMove x, y

    Reporter.ReportEvent micDone, "A step name", "A useful step description"
End Sub
RegisterUserFunc "Link", "MouseOver", "My_MouseOver"      //MouseOver method is registered
RegisterUserFunc "WebButton", "MouseOver", "My_MouseOver" //MouseOver method is registered 
Browser(<>").Page("<>").Link("<>").MouseOver //My_MouseOver function is called
Browser(<>").Page("<>").WebButton("<>").MouseOver //My_MouseOver function is called

- Issue with a browser, QTP detects two browsers but only one exist? --- Solved
Please check your Task Manager, UFT must be identifying any open instances of IE. 
Use “CloseProcessByName” function to kill any open IE instances in your code to rectify 
this.



No comments:

Post a Comment