Tuesday, March 25, 2014

VBScript - Change Date Format

Use case:
For the following Calendar, set second date 2 days later that first date:
'parse initia date and change the format from 25.03.14 to 25/03/14
Dim fromDate, toDate, parsedDate, i, fromDay, fromMonth, fromYear
parsedDate = Split(Browser("Browser_Local").WebEdit("From").GetROProperty("value"),".")
fromDay = parsedDate(0)
fromMonth = parsedDate(1)
fromYear = parsedDate(2)
fromDate =    fromMonth & "/" & fromDay & "/" & fromYear
fromDate =    CDate(fromDate)
'set the second date 2 days after 03/25/14 => 03/27/14
toDate = DateAdd("d","2",fromDate)
'set the second date in the desired format => 27.03.14
Dim strDate
strDate = Right("0" & DatePart("d",toDate)2) & "." & Right("0" & DatePart("m",toDate)2) & "." & Right(DatePart("yyyy",toDate),2)
'enter the value for the second date Browser("Browser_Local").Page("Ihr Seminar, Kurs, Coaching").RunScript("$('#Hotel_overnight_to_1').val('"& strDate &"')") 
'following is optional. in my case these elements needed to have values also
Dim oPage
Set oPage=Browser("Browser_Local").Page("Ihr Seminar, Kurs, Coaching")
Dim bisDay, bisMonth, bisYear
Set bisDay=oPage.RunScript("document.getElementsByName('hotel[overnight_to][1][day]')(0);")
bisDay.Value=Right("0" & DatePart("d",toDate)2)
Set bisMonth=oPage.RunScript("document.getElementsByName('hotel[overnight_to][1][month]')(0);")
bisMonth.Value=Right("0" & DatePart("m",toDate)2)
Set bisYear=oPage.RunScript("document.getElementsByName('hotel[overnight_to][1][year]')(0);")
bisYear.Value=DatePart("yyyy",toDate)    

Run Javascript in UFT (QTP)

 Browser("Browser_Local").Page("MyPage").RunScript("$('#Hotel_overnight_to_1').val('25.03.14')"
   
    Dim oPage
    Set oPage=Browser("Browser_Local").Page("MyPage"
      Dim bisDay, bisMonth, bisYear
     
    Set bisDay=oPage.RunScript("document.getElementsByName('hotel[overnight_to][1][day]')(0);"
    bisDay.Value="25"
   
    Set bisMonth=oPage.RunScript("document.getElementsByName('hotel[overnight_to][1][month]')(0);"
    bisMonth.Value="03"
   
    Set bisYear=oPage.RunScript("document.getElementsByName('hotel[overnight_to][1][year]')(0);"
    bisYear.Value="2014"

Source:
http://qtpcodes.blogspot.de/2011/10/running-javascript-in-qtp.html

Monday, March 24, 2014

Uninstall ALM-Client

1. Delete all files under following locations:
    %ALLUSERSPROFILE%\HP\ALM-Client
    %UserProfile%\AppData\Local\HP\ALM-Client
    %LocalAppData%\HP\ALM-Client
    %ALLUSERSPROFILE%\Application Data\HP\ALM-Client
    %UserProfile%\Local Settings\Application Data\HP\ALM-Client
    %temp%/td_80

2. Reopen ALM.

Source:
http://h30499.www3.hp.com/t5/Quality-Center-Support-and-News/How-do-I-uninstall-the-ALM-QC-v11-client/td-p/5616791#.UzAebvmSxlT 

Open ALM Client outside IE

If you need to open ALM-Client outside Internet Explorer you can open in IE following link:

http://ServerName/qcbin/start_a.jsp?embedclient=false

This will open ALM-Client.


Monday, March 17, 2014

UFT - Wait until Loading Icon is no longer displayed

I had something like this:

Search for something -> loading icon displayed until search is done -> results are displayed.
Here is the solution using XPath:

While Browser("Browser_Local").WebElement("xpath:=//div[contains(@class,'hitsArea')]/descendant::td[contains(@class,'cell-loadingIcon') and not(contains(@style,'display: none'))]").Exist = False
    wait 2
Wend

- It looks for the div, that contains a class named "hitsArea"
- finds between its descendants, one that contacins a class named "cell-loadingIcon"
- and it is not hidden: not(contains(@style,'display: none'))