Forum Discussion
1 Reply
Sort By
- Ryan_MoranValued ContributorThe URL will be contained within the page object Name and FullName properties.
Ex:
Sys.Browser("chrome").Page("http://smartbear.com/forums/f75/t91569/access-address-bar-google-chrome/")
Assuming you have only one page open you can retrieve the "address" like so:
//JScript
wshell = new ActiveXObject('WScript.Shell');
myCurrentURL = Sys.Browser("chrome").Page('*').Name.replace(/page\(/i,'').replace('\"','');
wshell.popup(myCurrentURL);
If you want an array returned of all pages I wrote this function for you:
//JScript
wshell = new ActiveXObject('WScript.Shell');
var myURLArray = listAllURL('chrome');
for (var c = 0;c < myURLArray.length;c++){
wshell.popup(myURLArray);
}
function listAllURL(myBrowser){
var urlList = [];
if (!Sys.WaitBrowser(myBrowser,0).Exists){
return urlList;
}
var browserArray = VBArray(Sys.FindAll('Name','*' + myBrowser + '*',1,true)).toArray();
for (var browser = 0;browser < browserArray.length;browser++){
var objectArray = VBArray(browserArray[browser].FindAll(['Name'],['*Page*'],1,true)).toArray();
for (var object = 0;object < objectArray.length;object++){
var pageName = objectArray[object].Name.replace(/page\(/i,'');
urlList.push(pageName.substr(1,pageName.length - 3));
}
}
return urlList;
}