Alert & Popup Window Handling in Selenium WebDriver (easy)

AwedExuberance avatar
AwedExuberance
·
·
Download

Start Quiz

Study Flashcards

30 Questions

Which type of alert in Selenium asks for user input?

Prompt Alert

Which type of alert in Selenium displays information or warning on the screen?

Simple Alert

What is the purpose of an alert in Selenium?

To display information or warning

How many types of alerts are there in Selenium?

3

What method can be used to handle a Prompt Alert in Selenium?

sendKeys()

What is the purpose of handling pop-up windows in Selenium?

To perform certain tasks

What is the purpose of handling multiple windows in Selenium?

To switch between different windows

What is the purpose of the accept() method in Selenium?

To accept a Confirmation Alert

What is the purpose of the dismiss() method in Selenium?

To dismiss a Confirmation Alert

What type of alert in Selenium provides warning messages?

Simple Alert

Which interface provides methods to handle alerts in Selenium WebDriver?

Alert

Which method is used to click on the 'Cancel' button of an alert?

dismiss()

Which method is used to click on the 'OK' button of an alert?

accept()

Which method is used to capture the alert message?

getText()

Which method is used to send data to an alert box?

sendKeys()

What is the return type of the getWindowHandles() method?

Iterator

What is the return type of the getWindowHandle() method?

String

Which method is used to handle the main window in Selenium WebDriver?

getWindowHandle()

What is the purpose of the 'Click Here' link in the Guru99 demo site?

To open a new child window

What is the purpose of the 'Submit' button in the Guru99 demo site?

To submit the page

Which method is used to switch to a child window in Selenium WebDriver?

switchTo().window()

What is the purpose of the getWindowHandles() method in Selenium WebDriver?

To handle all new opened windows

How do you close a child window in Selenium WebDriver?

driver.close()

What is the purpose of the switchTo().window() method in Selenium WebDriver?

To switch to a child window

Which method is used to switch to the parent window in Selenium WebDriver?

switchToParentWindow()

What is the purpose of the getWindowHandle() method in Selenium WebDriver?

To handle the current window

How do you maximize the browser window in Selenium WebDriver?

driver.maximize()

What is the purpose of the switchTo() method in Selenium WebDriver?

To handle all new opened windows

Which method is used to send keys to an element in Selenium WebDriver?

sendKeys()

What is the purpose of the get() method in Selenium WebDriver?

To launch a website

Study Notes

Alerts in Selenium

  • A Prompt Alert in Selenium is the type of alert that asks for user input.
  • An Alert in Selenium displays information or warning on the screen, and its purpose is to inform the user about a specific situation.
  • There are three types of alerts in Selenium: Alert, Confirm, and Prompt.
  • A Prompt Alert can be handled using the sendKeys() method.

Handling Alerts

  • The purpose of handling pop-up windows in Selenium is to interact with alert boxes, confirmations, and prompts.
  • The purpose of handling multiple windows in Selenium is to switch between different windows or tabs.

Alert Methods

  • The accept() method is used to click on the 'OK' button of an alert.
  • The dismiss() method is used to click on the 'Cancel' button of an alert.

Types of Alerts

  • A Confirm Alert in Selenium displays a warning message.
  • An Alert interface provides methods to handle alerts in Selenium WebDriver.

Methods for Handling Alerts

  • The getText() method is used to capture the alert message.
  • The sendKeys() method is used to send data to an alert box.
  • The dismiss() method is used to click on the 'Cancel' button of an alert.
  • The accept() method is used to click on the 'OK' button of an alert.

Window Handling

  • The getWindowHandles() method returns a set of window handles.
  • The getWindowHandle() method returns a string representing the current window handle.
  • The switchTo().window() method is used to switch to a child window.
  • The getWindowHandles() method is used to get a set of window handles, which can be used to switch between different windows.

Switching Between Windows

  • The switchTo().window() method is used to switch to a specific window.
  • The getWindowHandle() method is used to get the current window handle, which can be used to switch back to the parent window.

Browser Management

  • The maximize() method is used to maximize the browser window.
  • The switchTo() method is used to switch to a specific window or frame.

Other Methods

  • The get() method is used to navigate to a specific URL.
  • The sendKeys() method is used to send keys to an element.

Test your knowledge on handling alerts in Selenium and learn how to effectively handle different types of pop-up messages, including notifications, permissions, errors, and warnings.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free
Use Quizgecko on...
Browser
Browser