0% found this document useful (0 votes)
10 views1 page

Program 7

This Java program uses Selenium WebDriver to automate a login process on the Sauce Demo website. It initializes a ChromeDriver, navigates to the site, enters user credentials, and checks if the login was successful by verifying the presence of a menu button. The program includes commented-out code for closing the browser after the test.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Program 7

This Java program uses Selenium WebDriver to automate a login process on the Sauce Demo website. It initializes a ChromeDriver, navigates to the site, enters user credentials, and checks if the login was successful by verifying the presence of a menu button. The program includes commented-out code for closing the browser after the test.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Program 7

package driver;

import [Link];

import [Link];

import [Link];

public class program7 {

public static void main(String[] args) {

WebDriver driver = new ChromeDriver();

[Link]("[Link]

[Link]([Link]("user-name")).click(); //just for the click function

[Link]().window().maximize();

[Link]([Link]("user- name")).sendKeys("standard_user");

[Link]([Link]("password")).sendKeys("secret_sau ce1");

[Link]([Link]("submit-button")).click();

boolean flag = [Link]([Link]("//button[text()=\"Open


Menu\"]")).isDisplayed();

if (flag == true)

[Link]("Successfully logged in! hurRAY ");

/*[Link](); // terminate test window only

[Link](); //to Terminate all windows and test window */

You might also like