How to Get List Name of a SharePoint link in UFT

March 14, 2018

SharePoint is the webApp designed by Microsoft. But as per HP passport site SharePoint is compatible with UFT. Also While browsing through advancedqtp site  I got an idea how to automate sharePoint using UFT's descriptive Programming.  Now getting list name from a sharePoint link is tricky. Here is an example how to do that:

msgbox getListName("your_SharePoint_URL")

The implementation will be as follows:
Function getListName("your_SharePoint_URL")
// this is to close the all open IE
SystemUtil.CloseProcessByName "IEEXPLORE.exe"
// open the sharePoint url
SystemUtil.run "iexplore.exe",your_SharePoint_URL
// This piece of code to navigate to the list settings
Browser("MicClass:=Browser").Page("MicClass:=Page").Link("html tag:=A","text:=LisList Tools Group").click
Browser("MicClass:=Browser").Page("MicClass:=Page").Link("html tag:=A","text:=LisSettings").click
Browser("MicClass:=Browser").Page("MicClass:=Page").Sync
//now the trick is to click on the address bar to get the url having List Name Until and unless we 
//click on the address bar sharepoint will not display the modified url with list name.
//The below code will click on the address bar
Browser("MicClass:=Browser").Page("MicClass:=Page").WinObject("name:=AddressDisplay Control").click
wait 2
urlwithListName=Browser("MicClass:=Browser").GetROProperty("url")
// now the url will look like= sharepoint link along with listname=some encoded string
//In order to get the list name we need to split the url with "List=" 
afterCut=split(urlwithListName,"List=")
//afterCut(0) will contain remaining part
//afterCut(1) will contain encoded list name. To get the actual name of the list,we can create our own 
//decoder or the easiest way to get that is to open bing's url decoder.
//I have coded to go to the bing decoder
Browser("MicClass:=Browser").navigate("https://www.bing.com/search?q=url+decoder")
//It will open the url decoder 
//setting the encoded list name in the text 
Browser("MicClass:=Browser").Page("MicClass:=Page").Frame("micClass:=Frame","html id:=third5302","html 
tag:=IFRAME").WebEdit("micClass:=WebEdit","html id:=text","name:=WebEdit").set afterCut(1)
//Click on the button
Browser("MicClass:=Browser").Page("MicClass:=Page").Frame("micClass:=Frame","html id:=third5302",
"html tag:=IFRAME").WebButton("miClass:=WebButton","html id:=decode",
"html tag:=Button","name:=Decode").Click
//get the decoded List name
LisName=Browser("MicClass:=Browser").Page("MicClass:=Page").Frame("micClass:=Frame","html id:=third5302",
"html tag:=IFRAME").WebEdit("micClass:=WebEdit","html id:=text","name:=WebEdit").getROProperty("value")
// this is to close the all open IE
SystemUtil.CloseProcessByName "IEEXPLORE.exe"
getListName=ListName
End Function

This is how we should be able to get the list name from a sharePoint.

You Might Also Like

0 comments