AUT:- http://in.finance.yahoo.com
Test Steps:– Fill company name and click on “Get Quotes”.New page loads and click on “Historical Prices”
Solution:-
We will use “Descriptive Programming” and “Regular Expressions” to solve the problem in a easy and smart way.
Step1:- Look for unique properties to identify the objects on the page
Step2:- Use “Regular Expressions” to solve the problem of redefining the page objects when new page opens.
Code Part:-
‘Creating the Page object using DP and RG Expressions
Set objYahoo = Browser(“CreationTime:=0”).page(“url:=http://in.finance.yahoo.com.*”)
‘Function call to search stocks
fnStocks “infy”
Public function fnStocks(sCompany)
‘Setting the compnay name and clicking on Get Quotes
objYahoo.WebEdit(“html id:= txtQuotes”).Set sCompany
‘Clicking on the get Quotes button
objYahoo.webbutton(“html id:= btnQuotes”).Click
‘Clicking on historical data link and doing error handling
If objYahoo.link(“text:=Historical Prices”,“html tag:=A”).Exist(5) Then
objYahoo.link(“text:=Historical Prices”,“html tag:=A”).Click
reporter.ReportEvent 0,“Historical Data”,“Available for the company = “&sCompany
else
reporter.ReportEvent 1,“Historical Data”,“Not Available for the company = “&sCompany
End If
End Function