Logout using selenium web driver with dynamically handling the dropdown

Testing steps:

  1. Load the page using the given URL (Log in | Register (formsscasb.tk))
  2. Login using valid credentials → (Email: radhika.rakesh@jobinandjismi.com, Password: test@12345)
  3. Select the arrow dropdown near the account name at the top right of the page and selects the logout option

Dynamically handling the dropdown

Script:

public static void main(String[] args) throws Exception {

WebDriverManager.chromedriver().setup();

ChromeOptions options = new ChromeOptions();

options.addArguments(“start-maximized”);

WebDriver driver = new ChromeDriver(options);

driver.get(“https://www.formsscasb.tk/Formsscasb/Formsscasb/checkout.ssp?is=login&loginParam=false&login=T&fragment=login-register#login-register“);

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

driver.findElement(By.id(“login-email”)).sendKeys(“radhika.rakesh@jobinandjismi.com“);

driver.findElement(By.id(“login-password”)).sendKeys(“test@12345”);

driver.findElement(By.className(“login-register-login-submit”)).click();

Thread.sleep(5000);

//Handling the dynamic drop down

driver.findElement(By.xpath(“//div[@class=’header-welcome-profile-welcome-carret-icon’]”)).click();

Thread.sleep(3000);

driver.findElement(By.xpath(“(//a[contains(text(), ‘Sign Out’)])[1]”)).click();

System.out.println(driver.getTitle());

driver.quit();

}

Leave a comment

Your email address will not be published. Required fields are marked *