cancel
Showing results for 
Search instead for 
Did you mean: 

Verifiy link address on firefox

SOLVED
Highlighted
Occasional Contributor

Re: Verifiy link address on firefox

I tried it with this:

function CheckWebURL(UrlToCheck) {
  //Assuming that no need of browser exists check so just check if an url is given to be checked and if current browser current page url contains this url
 if (typeof MyValue == 'undefined'){
  var posUrl = aqString.Find(Sys.Browser("*").Page("*").URL, UrlToCheck, 0 , false);
  return ((UrlToCheck != "") && (posUrl >=0) && (posUrl < 9))
 }
 else{
  Log.Message("Error on identifying the link");
 }
}

And it's giving me error: Ms JScript Runtime error (Object doesn't support this property or method)

Highlighted
Community Leader

Re: Verifiy link address on firefox

lol ... no it was an example MyValue Smiley Happy

 

So here you must make that,

function CheckWebURL(UrlToCheck) { 
//Assuming that no need of browser exists check so just check if an url is given to be checked and if current browser current page url contains this url
if (typeof UrlToCheck == 'string') {
var posUrl = aqString.Find(Sys.Browser("*").Page("*").URL, UrlToCheck, 0 , false);
return ((UrlToCheck != "") && (posUrl >=0) && (posUrl < 9))
}
else {
Log.Message("UrlToCheck is incorrect");
return false;
}
}

typeof return the type of the variable

it could be 'undefined', 'string', 'number' or 'Object'  (array are included in Object)

Here you want a string, so checking if type is string is double check:  variable is definied and it's type is string.

 

On your function, MyValue is here not defined ...

And it will return return true, because by default function returns true. And you don't specify the return value in case of bad type (Log.Message doesn't change return value, Log.Error yes).

 

Good place to learn data type here:

https://www.w3schools.com/js/js_datatypes.asp

 

 

Un sourire et ça repart

View solution in original post

Highlighted
Occasional Contributor

Re: Verifiy link address on firefox

Hi, 

 

Thank you for helping me out. I found out that the firefox address bar field doesn't have 'text' property on it, so I decided to use other browsers (IE & Chrome) and it seems to work.

 

Thank you very much. And I will start to learn more about programming and TestComplete 🙂 

New Here?
Join us and watch the welcome video:
Top Kudoed Authors