Use of "verifyLocation" and "assertLocation" in selenium

"verifyLocation" Command
Soometimes you need to check the URL of current selected window to perform some actions. In such cases, selenium has two commands to verify the absolute URL of the current selected page. "verifyLocation" and "assertLocation".

"verifyLocation" command will just verify your trageted URL with absolute URL of the current page and returns error message if match not found and will go for executing next command. In bellow given example, first "verifyLocation" will becomes pass but 2nd "verifyLocation" will be fail because trageted URL will not
match with the absolute URL of the current page. But it will not stop execution and will go for executing next command.

New Test
CommandTargetValue
openhttps://www.google.co.in/
verifyLocationhttps://www.google.co.in/
verifyLocationhttps://www.yahoo.com
assertLocationhttps://www.yahoo.com
assertLocationhttps://www.google.co.in/

"assertLocation" Command
"assertLocation" Command will check and compare targeted URL with absolute URL of the current selected page and will return error message if both URLs not match. If "assertLocation" Command fails then selenium will stop execution of sript. In above example, 1st "assertLocation" Command will return error message so that next command will be not executed.

6 comments:

  1. How to check for all the broken links and pdf on a webpage using selenium ide ??

    ReplyDelete
  2. Best way to check all link in web page using webdriver.
    - You need to first targe a tag (css=a)
    - Loop a tag one by one
    - Fire Click command
    - Verify open window url using verifyLocation

    ReplyDelete
  3. Hey, is it possible to use verifyLoaction on a different URL's = meaning I wrote tests where i assertLocation and verifyLocation's on a website(dev1...admin.html, but now I want to know is there a way to assert/verifyLocation for ANY website URL's. So that my assert/verify-Lococation can run on any website other of my website's?

    ReplyDelete
  4. Hey, is it possible to use verifyLoaction on a different URL's = meaning I wrote tests where i assertLocation and verifyLocation's on a website(dev1...admin.html, but now I want to know is there a way to assert/verifyLocation for ANY website URL's. So that my assert/verify-Lococation can run on any website other of my website's?

    ReplyDelete