How to check if the script has navigated to the correct URL in Selenium?

How to check if the script has navigated to the correct URL in Selenium?

Hey Jacqueline,

First, you need to get the URL by the below method:

driver.getCurrentUrl();

And then need to verify if the URL is correct or not by using the assertions:

Assert.assertEquals(expectedUrl, driver.getCurrentUrl());