Find links in multiple ways using Xpath

Find All links in a page

function alllinks(){

ParentObj = Sys.Browser(“chrome”).Page(“https://services.smartbear.com/samples/TestComplete14/smartstore”)

ArrObj = ParentObj.FindElements(‘//*[@href]’)

Log.Message(ArrObj.length)

Log.Message(“Tester”)
}

Find Specific link

ParentObj = Sys.Browser(“chrome”).Page(“https://services.smartbear.com/samples/TestComplete14/smartstore”)
SingleObject = ParentObj.FindElement(“//*[@href and @title=’Sports’]”)
SingleObject.Click()

Find Any link

function Anylink(InputText){
ParentObj = Sys.Browser(“chrome”).Page(“https://services.smartbear.com/samples/TestComplete14/smartstore”)
AnyObject = ParentObj.FindElement(“//*[@href and @title= ” +”‘” +InputText +”‘”+ “]”)
AnyObject.Click()
}

function TestAnylink(){

Anylink(“Sports”)

}

Leave a comment