I login into - https://opensource-demo.orangehrmlive.com/web/index.php/auth/login Username : Admin Password : admin123
once i login ,i land on the Dashboard page the dashboard page URL is - https://opensource-demo.orangehrmlive.com/web/index.php/dashboard/index
now i want to compare actual and expected using Assert
actual URL =https://opensource-demo.orangehrmlive.com/web/index.php/dashboard/index expected = if the actual url contain dashboard word,then pass it else fail.
CAN SOME PLEASE HELP ME , I AM NEW
MY CODE
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
// LOGIN THE ORANGE HR
driver.get("https://opensource-demo.orangehrmlive.com/web/index.php/auth/login");
driver.manage().window().maximize();
Thread.sleep(1000);
driver.findElement(By.name("username")).sendKeys("Admin");
driver.findElement(By.name("password")).sendKeys("admin123");
driver.findElement(By.xpath("//button[@class='oxd-button oxd-button--medium oxd-button--
main orangehrm-login-button']")).click();
Thread.sleep(1000);
String URL = driver.getCurrentUrl();
boolean ExpectedURL = URL.contains("dashboard");
Assert.assertTrue(ExpectedURL, URL);`
actual URL =https://opensource-demo.orangehrmlive.com/web/index.php/dashboard/index expected = if the actual url contain dashboard word,then pass it else fail.
You can simply use String.contains() method, as the WebDriver.getCurrentUrl() method returns a String: