package junit4qtp;
import java.util.HashMap;
import java.util.Map;
import junit.framework.TestCase;
import qtpcommandserver.client.QTP;
public class FlexStoreTest_DynamicData extends TestCase
{
Map
public FlexStoreTest_DynamicData()
{
dataMap.put("phonePart1", "917");
dataMap.put("phonePart2", "123");
dataMap.put("phonePart3", "4567");
dataMap.put("password", "secretPass");
}
public String getParameter(String name)
{
return dataMap.get(name);
}
public void testHome() throws Exception
{
QTP.runTest(true, "resources/QTP/FlexStoreHomeTest-DynamicData", this);
}
}

From QTP script we calling back into our JUnit to get the data.
Function getParameter(name)
getParameter = JavaObject.invoke("getParameter", Array(name))
End Function
SystemUtil.Run "C:/Program Files/Internet Explorer/IExplore.exe", "http://examples.adobe.com/flex2/inproduct/lcds/flexstore/flexstore.html"
Browser("FlexStore").Sync
Window("hWnd:=" & Browser("FlexStore").Object.hWnd).Activate
Window("hWnd:=" & Browser("FlexStore").Object.hWnd).Maximize
Window("hWnd:=" & Browser("FlexStore").Object.hWnd).Resize 715, 720
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Home").FlexTextArea("index:31").Input(getParameter("phonePart1"))
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Home").FlexTextArea("index:33").Input(getParameter("phonePart2"))
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Home").FlexTextArea("index:35").Input(getParameter("phonePart3"))
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Home").FlexTextArea("index:37").Input(getParameter("password"))
if(Browser("FlexStore").FlexApplication("id:=flexstore").FlexCanvas("automationname:=Home").FlexCheckBox("automationname:=Remember my phone number").GetRoProperty("selected") = "True") Then
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Home").FlexCheckBox("Remember my phone number").Click
end if
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Home").FlexButton("Login").Click
Browser("FlexStore").FlexApplication("flexstore").FlexAlert("Login").FlexButton("OK").Click
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Home").FlexButton("Login").Click
if("This feature is not implemented in this sample" <> Browser("FlexStore").FlexApplication("id:=flexstore").FlexAlert("automationname:=Locate").GetRoProperty("text")) then
msgbox("error")
end if
Browser("FlexStore").FlexApplication("flexstore").FlexAlert("Login").FlexButton("OK").Click
Window("hWnd:=" & Browser("FlexStore").Object.hWnd).Close

4 comments:
You need to provide information for downloading and installing this.
I'm planning to make this software available early next year, when the code became stable and successfully using by my company. Also there are many things need to be done because I'm building a framework around this Junit4QTP project.
I'll regularly update my progress on this blog. I'll make the software available when it became mature and usefull.
Hi BPT4J,
Let me first applaud you for doing this..i mean,sharing with us about the possibility of stringing together Java and QTP in such a way.I wanted to do this and didnt know where to start..I even thought it was impossible..but thanks to you,i know it isn't.
Will be visiting your blog regularly.
Thanks again!
Post a Comment