Monday, August 29, 2011

20 Essential Addons for Fire fox

Hey guys,

If you are using fire fox as your testing browser, then you must have these 20 essential firefox addons.I found this article, once I wondering for some information. Hope you will also like it.

http://www.testinggeek.com/twenty-essential-firefox-addons-for-testing

Thanks,
Trupti

QTP: Working with Web Table

Hey folks,

Please find below code for working with Web table to get row count,  column count and fetch records from the web table.
URL=http://www.google.com/
Systemutil.Run "iexplore.exe",URL
browsernm=".*Google.*"
Pagenm=".*Google.*"
Set CurrObj=Browser("name:="&browsernm).Page("title:="&Pagenm)
wait(5)
CurrObj.WebEdit("name:=q","html tag:=input").Set "Web table in qtp"
CurrObj.WebButton("name:=Google Search").Click

'to find the row count from web table
wtblrowcnt=CurrObj.WebTable("name:=nav_logo14").rowcount
msgbox wtblrowcnt

'To find the column count from web table
wtblcolcnt=CurrObj.WebTable("name:=nav_logo14").columncount(1) 'column count argument is row number
msgbox wtblcolcnt

'To fetch the data from particular cell
celldata= CurrObj.WebTable("name:=nav_logo14").getcelldata(1,1)
msgbox celldata

'Get the row number for defined text
RowNumber = Browser("").Page("").WebTable("").GetRowWithCellText("Trupti")

'CellText works as same as GetCellData method
 Browser("").Page("").WebTable("index:=0").CellText(1,1) 


'CellTextbyContext returns the text within a cell delimited by a character. We can retrieve the text before '(or) after the delimiter using this method.
 ' Consider a cell having the text “Jethva;Trupti”. Here “;’ is the delimiter
 Browser("").Page("").WebTable("index:=0").CellTextByContext(1,1,"",";")  

'TextCellExist method checks whether a text exists in a cell or not. It returns true, if the input text exists 'in the cell, else it returns false. Rather than using GetCellData method and then comparing the result with 'the input text, we can achieve it using this simple method.
  Browser("").Page("").WebTable("index:=0").TextCellExist(1,1,"Trupti") 



Thanks,
Trupti

Wednesday, August 10, 2011

Excel Cell's format change to "Text" using QTP

Hi,

Hope this will help you for changing cell's format to "Text" using QTP. In excel we can do it using right click on cell and change the format of general to text. Same thing using QTP, we can do it as follows.

objXL.Columns(x).ColumnWidth = 20

objXL.ActiveSheet.Range("A:A").NumberFormat = "@"

Replace “A:A” with your

Thanks,
Trupti

Thursday, July 14, 2011

Retrive value from NotePad using QTP

Hey folks,

I tried to write function for retrive value from notepad and get particular data from it.
Precondition: Notepad line format should be same with some pattern like comma sepearted.

call opennotepad()
public function opennotepad()
Dim objFSO, fileName, objFile, strContents, str, position

Set objFSO = CreateObject("Scripting.FileSystemObject")
fileName = "D:\Trupti \folder\Automation\filename.txt"
Set objFile = objFSO.OpenTextFile(fileName,1,true)
reporter.ReportEvent micPass,"File open","File open successfully"
strContents1 = objFile.ReadLine
For I = 0 to 13 '13 is line count, we can write variable if it dynemic

strContents = objFile.ReadLine
DataTable.SetCurrentRow(I)
Call StoringValues(strContents)
field1=Trim(locfield1)
field2=Trim(locfield2)
Next

objFile.Close
Set objFile = nothing
Set objFSO = nothing
End Function

Public Function StoringValues(strContents)
locfield1=mid(strContents,2,22) ' in mid function-strcontent is string, 2 is start value, and 22 is upto 22 length of char data will retrive
localfield2=mid(strContents,87,5)
Endfunction