How to Check If Current URL Changes?

Is there a command that check if current url changes? Let say, http://sitename.com changes to http://sitename.com/pages after clicking a link, how to check if url changes?

I need to check if url changes because some site uses popup (which don’t change current url) while some site don’t use popup thus url changed.

Thank you.

It’s more simple to do this check

With this you can save current url

{
  "Command": "executeScript",
  "Target": "return (window.location.href)",
  "Value": "href",
  "Description": ""
},

You can check periodically and with IF_v2 you can know if url changed

1 Like

@newuserkantu Okay, correct me if i’m wrong, so basically the code to check if url changed is this right?

if_v2 : !URL == ${href} OR if_v2 : !URL =/= ${href} right?

Also do you think executeScript needed or can i use executeScript_sandbox for this? Thank you.

Your code macro is wrong, !URL can be used only when you load a page from ui vision.

My solution working in every cases and can detect url in every moment

@newuserkantu sorry but i’m noob at code so i don’t quite understand your solution. Maybe i’ll need to learn some javascript first to understand what you mean. Thank you.

The first usrl to compare what is ?

You have not explained well the work to be performed, when a url can be defined changed ?

And with which url should it be compared ? before you can automate a job you must have a good idea of what you need to do, at the moment you have not well explained what you intend to do.