In this video will see how to check if correct page is loaded or not. In order to do that will get the title of the page and perform a check.
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@pworld1990
Code:
public class VerifyPageLoad{
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "directory path of chrome driver exe\\chromedriver.exe");
ChromeOptions op = new ChromeOptions();
op.setBinary("directory path of chrome exe\\chrome.exe");
op.addArguments("--remote-allow-origins=*");
WebDriver driver = new ChromeDriver(op);
driver.get("https://programmerworld.co/");
String actualResult = driver.getTitle();
System.out.println(actualResult);
String expectedResult = "Welcome to Programmer World ! - programmerworld ";
if(actualResult.equals(expectedResult)) {
System.out.println("Test is passed!!!!");
}else
System.out.println("test is failed!!!!, expected Result is = " +expectedResult+" but actual result is = " +actualResult);
}
}
Excerpt:
In this video, we will learn how to verify if the correct page has loaded by obtaining the page title and performing a check. The provided code demonstrates the use of Selenium WebDriver to achieve this verification on the “https://programmerworld.co/” webpage. If the actual result matches the expected result, the test is considered passed; otherwise, it is marked as failed. If you have any questions, suggestions, or feedback, please feel free to contact us at https://programmerworld.co/contact/ or via email at programmerworld1990@pworld1990.