Thursday, 22 December 2011

How to Store Value from Webpage in Spacific Cell in Excel Sheet


Problem:
*******************
1. Search for specific lenses on mentioned website and note down its price.
2. Place that price in Excel sheet (inside Specific Column) as other columns have formula reference to that price

Solution:
*********************
I created an automated script that perform the following actions

1. Open browser and mentioned Website (http://www.cameraaction.com.au(
2. Move to that specific page (e.g Sony Lenses page)
3. Check only lenses that are required
4. Copy the prices in the excel sheet (At specific locations).

QTP Script
*******************************************
'Store spacific values in a & b variable

a= browser("Camera Action Camera House").Page("Camera Action Camera House").WebElement("qty_1").GetROProperty("Text")
b= browser("Camera Action Camera House").Page("Camera Action Camera House").WebElement("qty_2").GetROProperty("Text")

'Create Excel object a and open test file.xls that is placed at C Drive

Set oExcel = CreateObject("Excel.Application")
Set oWorkBook = oExcel.Workbooks.Open("C:\test file.xls")
Set ExcelSheet=createObject("Excel.sheet")
'Store value of a in Cell I5
oExcel.ActiveSheet.cells(5,"I").value= a
'Store value of b in Cell I8
oExcel.ActiveSheet.cells(8,"I").value= b
'Save Workbook
oWorkBook.Save

No comments:

Post a Comment