InterviewSolution
| 1. |
How to send a value into alert? |
|
Answer» Alerts is a popup box that takes focus away from the current browser and forces you to read the alert message. Some activities such as accepting or dismissing the alert box need to be performed to resume your task on the browser. To handle alerts popup window, we need to call the SELENIUM WEBDRIVER Alert API method to switch to the alert window. Window-based and Web/Browser based alert are the two types of alert. To handle Browser-based Alerts (alert popup), we use Alert Interface which provides some methods to handle the popup. During the execution of the WebDriver script, the driver control will be on the browser. Even when after the alert generated control will be on a browser that means the driver control will be behind the alert pop up. In order to move the control to alert pop up, use the COMMAND – driver.switchTo().alert();After SWITCHING control from browser to alert window, we can use the Alert Interface methods to perform actions such as accepting the alert, dismissing the alert, GET the text from the alert window, writing some text on the alert window, etc., Syntax send the value to the alert is - alert.sendkeys(String tringToSend); |
|