Skip to main content

Alert Handling in Selenium Web Driver

Alert have only Accept and Cancel button which which have only text in title of alert, Accept the alert, cancel the alert and provide some value/text in the alert. following is the process how to handle the alert with Selenium Web driver.
Here when user click on the change text then a alert box is opening which needed to handle.
Here in this we need to get the title of the alert, Cancel the alert, Provide value for alert text box and then accept the alert.
here you can change the URL in which you are checking and corresponding the locators to locate the web elements.
getText(): to get the alert title
sendkeys(): to provide the input to the alert
accept(): Accept the alert box
dismiss(): cancel the alert box

below is the sample code to show an alert box


 In the below code of selenium, You can have the idea regarding the get text and accept the alert box.


Now in below code sample you can understand the dismiss function of alert




Below is the code to understand this dismiss() function

 
 Now in below sample code i will let you know that how sendkeys() function will work in alert



Below is the code to understand this function

 

Comments

Popular posts from this blog

Why Jmeter is best option for Performance Testing?

There are multiple tools in market for performance testing of any software but Jmeter is the best solution among all of them due to some reason listed below 1) Jmeter is the open source application so users who use this application will not to pay anything. 2) You can use Jmeter for performance of any web application,  Databases and Web Services (REST and SOAP APIs). 3) Jmeter have the user friendly UI component so it is very easy to use. 4) Jmeter can be used to simulate to put maximum number of concurrent users on a server, network or object to test its strength or to analyze overall performance under different load types. 5) Jmeter also use for functional testing for static( JavaScript and HTML) and dynamic( JSP, Servlets and AJAX) resources. 6) Jmeter provides Verity of graphical representations for performance report so it is easy to understand.

How You Can Test Database?

Now we know the Database Testing which you can learn in my last article. In this article we will discuss about the steps that need to following to test any Database. Database Tester should have some basic knowledge regarding SQL Command like DDL (create/drop),  DML (Insert/Delete/Update) and DCL (Grant/Revoke).

Causes of Software Defects

It is practically impossible that developer develop a bug free software and that software we can deliver without Testing. If the complexity of the software increased then there must be bugs that can harm the users who will use that software.