If you find yourself in a situation where UFT (QTP) identifies an object in Object Repository but doesn't click on it, here is something to try:
Setting.WebPackage("ReplayType") = 2 'Mouse
Browser(" ").Page(" ").WebEdit(" ").Set "bla"
Browser(" ").Page(" ").WebButton(" ").Click
Setting.WebPackage("ReplayType") = 1 'Events
For more detail read this: http://www.knowledgeinbox.com/articles/qtp/settings/when-to-change-qtp-web-replaytype-setting/
Friday, November 1, 2013
Tuesday, October 15, 2013
QTP / UFT - Manually unlock test
Pretty useful:
1) Have everyone close their QTP / UFT scripts and log out of the project
2) Log into site admin, expand the project, and select the locks table. If any records appear in the locks table, run the
following SQL query in the text box above the results.
DELETE FROM LOCKS WHERE LK_USER = 'username' AND
LK_OBJECT_TYPE = 'TEST'
a. Note: username needs to be replaced with a username in the LK_USER column from the results above.
3) Users should now be able to log back into the project and access the QTP / UFT scripts.
1) Have everyone close their QTP / UFT scripts and log out of the project
2) Log into site admin, expand the project, and select the locks table. If any records appear in the locks table, run the
following SQL query in the text box above the results.
DELETE FROM LOCKS WHERE LK_USER = 'username' AND
LK_OBJECT_TYPE = 'TEST'
a. Note: username needs to be replaced with a username in the LK_USER column from the results above.
3) Users should now be able to log back into the project and access the QTP / UFT scripts.
Source:
Monday, October 14, 2013
UFT (QTP) - Find Element by Properties
If you need to find a specific element with UFT (QTP) here is something to try:
Note: you can choose what properites to use:
Function GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Dim Desc
Set Desc = Description.Create()
Desc("micclass").Value = MicClass
Desc("innertext").Value = Innertext
Desc("html tag").Value = HTMLTag
Set GetAllSpecificControls = Page.ChildObjects(Desc)
End Function
Function FindMyObject(Page, MicClass, Innertext, HTMLTag)
Select Case MicClass
Case "WebButton"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "WebElement"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "Image"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "Link"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "Static"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "WebEdit"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "WebList"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case Else
myReport micFail, "An object of type """ & MicClass & """ could not be found!"
ExitIfError
End Select
End Function
'Function call example
FindMyObject(Browser("Browser_Local").Page("Page"), "WebElement", "ObjectToBeFoundInnertext", "STRONG")(0).Click
Note: you can choose what properites to use:
Function GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Dim Desc
Set Desc = Description.Create()
Desc("micclass").Value = MicClass
Desc("innertext").Value = Innertext
Desc("html tag").Value = HTMLTag
Set GetAllSpecificControls = Page.ChildObjects(Desc)
End Function
Function FindMyObject(Page, MicClass, Innertext, HTMLTag)
Select Case MicClass
Case "WebButton"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "WebElement"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "Image"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "Link"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "Static"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "WebEdit"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case "WebList"
Set FindMyObject = GetAllSpecificControls(Page, MicClass, Innertext, HTMLTag)
Case Else
myReport micFail, "An object of type """ & MicClass & """ could not be found!"
ExitIfError
End Select
End Function
'Function call example
FindMyObject(Browser("Browser_Local").Page("Page"), "WebElement", "ObjectToBeFoundInnertext", "STRONG")(0).Click
Thursday, September 26, 2013
Windows Phone 8 development - Change icon color depending on phone background
Smart way to change icon color:
<Border x:Name="Wifi" Width="76" Height="76"
HorizontalAlignment="Right" VerticalAlignment="Bottom"
Background="{StaticResource PhoneForegroundBrush}" Margin="0,0,360,82" Tap="WhenTappedWifi" >
<Border.OpacityMask>
<ImageBrush ImageSource="Assets/Tiles/Custom/wifi.png" />
</Border.OpacityMask>
</Border>
<Border x:Name="Wifi" Width="76" Height="76"
HorizontalAlignment="Right" VerticalAlignment="Bottom"
Background="{StaticResource PhoneForegroundBrush}" Margin="0,0,360,82" Tap="WhenTappedWifi" >
<Border.OpacityMask>
<ImageBrush ImageSource="Assets/Tiles/Custom/wifi.png" />
</Border.OpacityMask>
</Border>
Windows Phone 8 - Navigate To and From Page
I needed a solution to change the state of an element when going back to the page where it was.
I tried the Loaded event, but this did not do the trick.
What worked was Page Navigation:
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
// code
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// code
}
Source: http://nicksnettravels.builttoroam.com/post/2011/03/07/Windows-Phone-7-Tombstone-Frustration.aspx
I tried the Loaded event, but this did not do the trick.
What worked was Page Navigation:
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
// code
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// code
}
Source: http://nicksnettravels.builttoroam.com/post/2011/03/07/Windows-Phone-7-Tombstone-Frustration.aspx
Tuesday, September 24, 2013
Windows Phone 8 Apps - Icon collection sources
I have found myself looking for icons many times.
So I have decided to create a list with good sources.
Here it is, to be continued...
http://www.geekchamp.com/icon-explorer/introduction
So I have decided to create a list with good sources.
Here it is, to be continued...
http://www.geekchamp.com/icon-explorer/introduction
Windows Phone 8 - Launch built-in apps - LaunchUriAsync
Few functions with LaunchUriAsync method:
Example:
http:[URL] | To launch web browser and navigate to specific web URL address |
mailto:[email-address] | To launch email app with To is set to email-address specified |
ms-settings-accounts: | To open Account Settings app |
ms-settings-airplanemode: | To launch Airplane Settings app |
ms-settings-bluetooth: | To launch Bluetooth Settings app |
ms-settings-cellular: | To open Cellular Settings app |
ms-settings-emailandaccounts: | To launch Email and Accounts Settings app |
ms-settings-location: | To display Locations Settings app |
ms-settings-lock: | To launch Lock Screen Settings app |
ms-settings-wifi: | To open Wi-Fi Settings app |
zune:navigate?appid=[App Id] | To navigate to app details page on Windows Phone Store |
zune:reviewapp | To open review page for calling app on Windows Phone Store |
zune:reviewapp?appid=[App Id] | To launch reviews page for specified app |
zune:search?[search parameter]=[value] | To search Windows Phone Store |
zune:search?keyword=[search keyword]&contenttype=app | To search Windows Phone apps by keyword |
zune:search?publisher=[publisher name] | To launch Windows Store and search publishers apps |
Example:
private async void WhenTappedWifi(object sender, System.Windows.Input.GestureEventArgs e)
{
Uri uri = new Uri("ms-settings-wifi:");
await Windows.System.Launcher.LaunchUriAsync(uri);
}
{
Uri uri = new Uri("ms-settings-wifi:");
await Windows.System.Launcher.LaunchUriAsync(uri);
}
Source:
Friday, September 20, 2013
Increase 250 users limit using command line
If you need to perform Load Tests in Visual Studio with more than 250 users, here is what you need to do:
1. Click Start -> All Programs -> Microsoft Visual Studio 2010 ->Visual Studio Tools, and then right-click Visual Studio 2010 Command Prompt -> Run as Administrator.
2. Type the following command:
VSTestConfig Licenses /AddKey:AAAAA-BBBBB-CCCCC-DDDDD-EEEEE.
Note: To get the license key:
- login to your MSDN Subscription -> My Product Keys ( https://msdn.microsoft.com/en-us/subscriptions/keys/ ) -> Visual Studio 2010 -> Visual Studio Load Test Virtual User Pack 2010
Source:
Monday, September 16, 2013
Add Last Save Date to Word Documents
In case you want to keep track when a document was last saved, here is what you need to do:
1. On the Insert tab, in the Text group, click Quick Parts ->Field.
3. In the Categories box, click Date and Time.
4. In the Field names box, click CreateDate, PrintDate, or SaveDate.
5. In the Date formats box, click the date and time format that you want — for example, 2/12/2008 9:45 PM or 12 February 2008.
Source:http://office.microsoft.com/en-001/word-help/insert-the-date-and-time-a-document-was-created-last-printed-or-last-saved-HA010100340.aspx
Wednesday, August 21, 2013
Permissions for creating Business Process Tests and FLows
You need to assign your user account to BPTester group.
Here what you need to do:
1. Open project in QC (ALM).
2. Go to Tools -> Customize -> Groups and Permissions.
Note! This is available only if you are a project administrator.
Note!! This is available only if your ALM is version11.50 or later.
3. Add your user to BPTester Group.
Creating Business Process Test or Flow is supported only starting with ALM 11.50.
If you get this message when trying to create a new Business Process Test or Flow, you probably have an older ALM (like 11.0).
Here what you need to do:
1. Open project in QC (ALM).
2. Go to Tools -> Customize -> Groups and Permissions.
Note! This is available only if you are a project administrator.
Note!! This is available only if your ALM is version11.50 or later.
3. Add your user to BPTester Group.
Creating Business Process Test or Flow is supported only starting with ALM 11.50.
If you get this message when trying to create a new Business Process Test or Flow, you probably have an older ALM (like 11.0).
Wednesday, July 24, 2013
Extract text between Tags
Here is the function, useful for extracting strings from xml files:
string ExtractString(string s, string tag)
{
var startTag = "<" + tag + ">";
int startIndex = s.IndexOf(startTag) + startTag.Length;
int endIndex = s.IndexOf("</" + tag + ">", startIndex);
return s.Substring(startIndex, endIndex - startIndex);
}
Example of call:
string initial = "<Create>Text to retrieve</Create>";
textToRetrieve=ExtractString(initial,"Create");
Result:
The value of textToRetrieve will be "Text to retrieve".
string ExtractString(string s, string tag)
{
var startTag = "<" + tag + ">";
int startIndex = s.IndexOf(startTag) + startTag.Length;
int endIndex = s.IndexOf("</" + tag + ">", startIndex);
return s.Substring(startIndex, endIndex - startIndex);
}
Example of call:
string initial = "<Create>Text to retrieve</Create>";
textToRetrieve=ExtractString(initial,"Create");
Result:
The value of textToRetrieve will be "Text to retrieve".
Tuesday, July 16, 2013
UFT - API Testing save test steps results
In UFT you might need to save the results of a step for further use, or see the results in the generated reports.
Here are some useful options:
1. Write to test Output Properties:
CodeActivity<x>.Output.PropertyName = "string property value";
2. Write to test profile:
CodeActivity<x>.Context.TestProfile.SetVariableValue("variable name","variable value");
3. Write to Output Console:
this.CodeActivity<x>.Context.UserLogger.InfoFormat("some string you want to see");
4. Write to generated Report after Run.
this.CodeActivity<x>.Report("some string you want to see");
Here are some useful options:
1. Write to test Output Properties:
CodeActivity<x>.Output.PropertyName = "string property value";
2. Write to test profile:
CodeActivity<x>.Context.TestProfile.SetVariableValue("variable name","variable value");
3. Write to Output Console:
this.CodeActivity<x>.Context.UserLogger.InfoFormat("some string you want to see");
4. Write to generated Report after Run.
this.CodeActivity<x>.Report("some string you want to see");
Thursday, July 11, 2013
C# - Get Computer Name
string hostName = Environment.MachineName;
string name = System.Net.Dns.GetHostName();
string name1 = System.Windows.Forms.SystemInformation.ComputerName;
string name2 = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
Wednesday, July 10, 2013
UFT - Return formated Date
I needed to get current date in this specific format: 2013-07-10T10:03:45.285+03:00
then, make it available for future activities, so here is what I did:
1. Created a Custom Code activity "GetTodayDate".
2. Added a Result Output Property.
Name: Result
Type: String
3. Go to Events Tab -> Create a default handler... for ExecuteEvent
public void CodeActivity22_OnExecuteEvent(object sender, STActivityBaseEventArgs args)
{
string date = XmlConvert.ToString(DateTime.Now,XmlDateTimeSerializationMode.Local);
CodeActivity22.Output.Result = date;
}
5. Result:
6. Now I can link the Result and use it in future activities.
Friday, July 5, 2013
UFT - Postgres on Windows via ODBC
For API testing in UFT (HP Unified Functional Testing) you might need to connect to a Postgres database.
1. For this you need to get an ODBC driver for Postgres:
http://www.postgresql.org/ftp/odbc/versions/msi/
2. Install it.
3. Go to %systemdrive%\Windows\SysWoW64 and add the Driver.
4. In UFT go to Data pane -> New Data Source -> Database and add database info.
1. For this you need to get an ODBC driver for Postgres:
http://www.postgresql.org/ftp/odbc/versions/msi/
2. Install it.
3. Go to %systemdrive%\Windows\SysWoW64 and add the Driver.
4. In UFT go to Data pane -> New Data Source -> Database and add database info.
Wednesday, April 17, 2013
Object Lock error in HP ALM (QC)
If you get an Object Lock error in QC ("Object locked by 'username' ") here are the steps to solve it:
1. Go to Site Administration.
2. Search for the corresponding Project.
3. Find the LOCKS table.
4. Execute following script:
DELETE FROM LOCKS WHERE LK_USER = 'username'
1. Go to Site Administration.
2. Search for the corresponding Project.
3. Find the LOCKS table.
4. Execute following script:
DELETE FROM LOCKS WHERE LK_USER = 'username'
Subscribe to:
Posts (Atom)