{"id":106354,"date":"2020-08-20T10:00:50","date_gmt":"2020-08-20T07:00:50","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=106354"},"modified":"2020-08-10T16:29:30","modified_gmt":"2020-08-10T13:29:30","slug":"webdriverio-tutorial-handling-alerts-overlay-in-selenium","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html","title":{"rendered":"WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium"},"content":{"rendered":"<p>You\u2019d hardly find a website these days without alerts and pop-ups! The alert boxes warn you whenever you perform a wrong action or to enter details to access a website. These alert boxes stop you from performing any other browser functions till the alert is resolved. This is why it becomes important that you handle them in your Selenium test automation scripts.<\/p>\n<p>In this WebDriverIO tutorial on alert handling in Selenium, I\u2019ll show you how to handle alerts &amp; pop-ups as well as overlay modal in WebDriverIO. I will also cover the different types of alerts you will face during automation and what are the key points you need to follow for alert handling in Selenium using WebDriverIO.<\/p>\n<h2 class=\"wp-block-heading\">Types Of Alerts In WebDriverIO<\/h2>\n<p>Alerts and pop-ups are pretty common in any website development, and while performing Selenium test automation you have to handle them as well. These alerts or rather javascript alerts, are pop up that takes your attention away from the current browser and forces you to read them. You won\u2019t be able to perform any further browser action if you don\u2019t know how to handle the alerts, this stands true for both manual and automation.<\/p>\n<p>It is important to note that you can\u2019t identify alerts using devtools or by XPath. Also, since they can\u2019t be handled as a window, this is why it gets a bit tricky to handle them, but don\u2019t worry, you\u2019d find more about this in the latter section of this WebDriverIo tutorial.<\/p>\n<p>There are three types of alerts that you\u2019d need to handle in WebDriverIO.<\/p>\n<ol class=\"wp-block-list\">\n<li>Alert pop up<\/li>\n<li>Confirmation Alert<\/li>\n<li>Prompt pop up<\/li>\n<\/ol>\n<h3 class=\"wp-block-heading\">Alert Pop Ups<\/h3>\n<p>The alert pop up or alert() method displays an alert box with just a message and \u2018OK\u2019 button. This alert used to inform the user about some information. There is only one button \u2018OK\u2019 displayed with the text of information. Here, the user has only one option to press the OK button. Below is the example of alert pop up.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-05-03-at-8.44.13-PM-1024x458.png\" alt=\"\" class=\"wp-image-106395\" width=\"768\" height=\"344\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-05-03-at-8.44.13-PM-1024x458.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-05-03-at-8.44.13-PM-300x134.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-05-03-at-8.44.13-PM-768x343.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-05-03-at-8.44.13-PM-1536x686.png 1536w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-05-03-at-8.44.13-PM.png 1600w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><figcaption><em><a href=\"http:\/\/the-internet.herokuapp.com\/javascript_alerts\" target=\"_blank\" rel=\"noreferrer noopener\">Image Source<\/a><\/em><\/figcaption><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\">Confirmation Alert<\/h3>\n<p>The confirmation alert is the second type of alert with a message, where it gives the user the option to press OK or Cancel. Here is the example of a confirmation alert.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Confirmation-Alert-1024x496.png\" alt=\"\" class=\"wp-image-106396\" width=\"768\" height=\"372\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Confirmation-Alert-1024x496.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Confirmation-Alert-300x145.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Confirmation-Alert-768x372.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Confirmation-Alert-1536x744.png 1536w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Confirmation-Alert.png 1600w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\">Prompt Pop up<\/h3>\n<p>The prompt pop up is the last alert where this used to let the user give input for the website. Here, the user can give input and press the OK button or press Cancel to avoid giving input. Below is the example of the prompt pop up.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Prompt-Pop-up-1-1024x445.png\" alt=\"\" class=\"wp-image-106398\" width=\"768\" height=\"334\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Prompt-Pop-up-1-1024x445.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Prompt-Pop-up-1-300x131.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Prompt-Pop-up-1-768x334.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Prompt-Pop-up-1-1536x668.png 1536w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Prompt-Pop-up-1.png 1600w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>Apart from these in-built javascript alerts, there is also one more pop up which is known as modal. The main difference between an alert and modal is that alert can not go off without requested actions e.g, OK, or Cancel. In the modal, it is made using the <code>&lt; div &gt;<\/code> tag by giving special CSS code. This modal can go off by clicking somewhere other than the modal.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.lambdatest.com\/lt-browser\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/LT-Browser-II-1.jpg\" alt=\"\" class=\"wp-image-106400\" width=\"698\" height=\"135\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/LT-Browser-II-1.jpg 930w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/LT-Browser-II-1-300x58.jpg 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/LT-Browser-II-1-768x149.jpg 768w\" sizes=\"(max-width: 698px) 100vw, 698px\" \/><\/a><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\">Overlay Modal<\/h3>\n<p>This modal is built using the client-side framework e.g bootstrap, ReactJS. A developer can be used to display some information, pop up, and form. There is no special<\/p>\n<p>Here is an example of Overlay Modal:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Overlay-Modal-1024x436.png\" alt=\"\" class=\"wp-image-106402\" width=\"768\" height=\"327\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Overlay-Modal-1024x436.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Overlay-Modal-300x128.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Overlay-Modal-768x327.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Overlay-Modal.png 1504w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>Now, that you are familiar with a different kind of alert and modal available in javascript. I\u2019ll show you more about alert handling in Selenium in this WebDriverIO tutorial.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><a href=\"https:\/\/www.lambdatest.com\/blog\/webdriverio-tutorial-run-your-first-automation-script\/\" target=\"_blank\" rel=\"noopener noreferrer\">WebDriverIO Tutorial: Run Your First Automation Script<\/a><\/p>\n<h2 class=\"wp-block-heading\">Alert Handling In Selenium Using WebDriverIO<\/h2>\n<p>If you are familiar with alert handling in Selenium test automation with other frameworks, you\u2019d assume that you\u2019d have to switch to the alert before alert handling in Selenium. .For example in Java, you have to create switchTo() method and then need to access the alert() method in order to perform an action. This is not the case here, you\u2019ll see how as we further progress in this WebDriverIO tutorial. For Selenium C# lovers, we have previously covered and article on <a href=\"https:\/\/www.lambdatest.com\/blog\/selenium-c-tutorial-handling-alert-windows\/\" target=\"_blank\" rel=\"noopener noreferrer\">alert handling in Selenium C#<\/a> , feel free to check it out.<\/p>\n<p>For example,<\/p>\n<div>\n<div id=\"highlighter_541371\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java plain\">driver.switchTo().alert().accept();<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>Similarly, dismiss(), sendkeys() methods are also accessible.<\/p>\n<p>Since you do not have to use the switchTo() method before alert handling in Selenium, it gets a tad bit easier to perform Selenium test automation.<\/p>\n<p>The methods you\u2019d need for alert handling in Selenium for <a href=\"https:\/\/www.lambdatest.com\/selenium-automation\" target=\"_blank\" rel=\"noopener noreferrer\">automated browser testing<\/a> are:<\/p>\n<ul class=\"wp-block-list\">\n<li>acceptAlert()<\/li>\n<li>dismissAlert()<\/li>\n<li>getAlertText()<\/li>\n<li>sendAlertText()<\/li>\n<li>isAlertOpen()<\/li>\n<\/ul>\n<p>The big advantage of WebDriverIO is that alerts can be accessed directly from the driver or browser object for Selenium test automation. E.g<\/p>\n<div>\n<div id=\"highlighter_140465\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java plain\">browser.acceptAlert();<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"java plain\">browser.dismissAlert();<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"java plain\">browser.getAlertText();<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"java plain\">browser.sendAlertText();<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"java plain\">browser.isAlertOpen();<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3 class=\"wp-block-heading\">acceptAlert()<\/h3>\n<p>acceptAlert() method is similar to <b>driver.switchTo().alert().accept()<\/b> selenium java. It helps users to click on the \u2018OK\u2019 button on Alert pop up.<\/p>\n<p>Syntax:<\/p>\n<p><code>browser.acceptAlert();<\/code><\/p>\n<p>Example:<\/p>\n<pre class=\"brush:java\">describe(\"This is example of Alert pop up \", function () {\n   it(\"Simple Alert pop up\", function () {\n       browser.url(\"http:\/\/the-internet.herokuapp.com\/\");\n       browser.pause(5000);\n       $(\"=JavaScript Alerts\").click();\n       browser.pause(5000);\n       $(\".\/\/button[text()='Click for JS Alert']\").click();\n       browser.pause(5000);\n       browser.acceptAlert();\n       browser.pause(5000);\n   });\n});\n<\/pre>\n<h3 class=\"wp-block-heading\">dismissAlert()<\/h3>\n<p>dismissAlert() method is used to click on the \u2018Cancel\u2019 button. If you compare this method with In selenium java then it is like <strong>driver.switchTo().alert().dismiss()<\/strong><\/p>\n<p>Syntax:<\/p>\n<p><code>browser.dismissAlert();<\/code><\/p>\n<p>Example:<\/p>\n<pre class=\"brush:java\">describe(\"This is example of Alert pop up \", function () {\n   it(\"comfirmation pop up\", function () {\n       browser.url(\"http:\/\/the-internet.herokuapp.com\/\");\n       browser.pause(5000);\n       $(\"=JavaScript Alerts\").click();\n       browser.pause(5000);\n       $(\".\/\/button[text()='Click for JS Confirm']\").click();\n       browser.pause(5000);\n       browser.dismissAlert();\n       browser.pause(5000);\n   });\n});\n<\/pre>\n<h3 class=\"wp-block-heading\">getAlertText()<\/h3>\n<p>getAlertText() method is used to read the message written on pop up. This is similar to <strong>driver.switchTo().alert().getText()<\/strong> in the Selnium java.<\/p>\n<p>Syntax:<\/p>\n<p><code>browser.getAlertText();<\/code><\/p>\n<p>Example:<\/p>\n<pre class=\"brush:java\">describe(\"This is example of Alert pop up \", function () {\n    it(\"getAlertText() pop up\", function () {\n       browser.url(\"http:\/\/the-internet.herokuapp.com\/\");\n       browser.pause(5000);\n       $(\"=JavaScript Alerts\").click();\n       browser.pause(5000);\n       $(\".\/\/button[text()='Click for JS Confirm']\").click();\n       browser.pause(5000);\n       const msg = browser.getAlertText();\n       console.log(msg);\n       browser.pause(5000);\n       browser.acceptAlert();\n       browser.pause(5000);\n   });\n});\n<\/pre>\n<h3 class=\"wp-block-heading\">sendAlertText()<\/h3>\n<p><strong>sendAlertText()<\/strong> method is used to send input to the textbox displayed on the prompt pop up. This method has one parameter which passed to send text to the input box. sendAlertText() method is similar to <strong>driver.switchTo().alert().sendKeys()<\/strong> in the Selenium Java.<\/p>\n<p>Syntax:<\/p>\n<p><code>browser.sendAlertText(String str)<\/code><\/p>\n<p>Example:<\/p>\n<pre class=\"brush:java\">describe(\"This is example of Alert pop up \", function () { \n  it(\"sendAlertText() Pop up \", function () {\n       browser.url(\"http:\/\/the-internet.herokuapp.com\/\");\n       browser.pause(5000);\n       $(\"=JavaScript Alerts\").click();\n       browser.pause(5000);\n       $(\".\/\/button[text()='Click for JS Prompt']\").click();\n       browser.pause(5000);\n       browser.sendAlertText(\"This is Input Text\");\n       browser.pause(5000);\n       browser.acceptAlert();\n       browser.pause(5000);\n   });\n});\n<\/pre>\n<h3 class=\"wp-block-heading\">isAlertOpen()<\/h3>\n<p><strong>isAlertOpen(<\/strong>) method is used to check whether the alert is visible or not. This method returns a boolean value to the user and based on this boolean value user can make a decision.<\/p>\n<p>Syntex:<\/p>\n<p><code>browser.isAlertOpen()<\/code><\/p>\n<p>Example:<\/p>\n<pre class=\"brush:java\">describe(\"This is example of Alert pop up \", function () {\n  \n   it(\"isAlertOpen check pop up\", function () {\n       browser.url(\"http:\/\/the-internet.herokuapp.com\/\");\n       browser.pause(5000);\n       $(\"=JavaScript Alerts\").click();\n       browser.pause(5000);\n       $(\".\/\/button[text()='Click for JS Alert']\").click();\n       browser.pause(5000);\n       const isOpen = browser.isAlertOpen();\n\n       if (isOpen) {\n           console.log(\"===========&gt;\" + isOpen);\n           browser.acceptAlert();\n           browser.pause(5000);\n       }\n   });\n});\n<\/pre>\n<h2 class=\"wp-block-heading\">Handling Overlay Modal Using WebDriverIO<\/h2>\n<p>By now you already know the difference between Alerts and Overlay Modal in this WebDriverIO tutorial. An alert can be closed only by the intended action, while overlay modal can be closed by clicking anywhere on the background. I\u2019ll now show you how to automate Overlay Modal using WebDriverIO.<\/p>\n<p>When you are automating the modal you do not have to work on special code or class. You just find out the object of the element directly using the WebDriverIO selector and perform the operation.<\/p>\n<p>Here is how you can handle Overlay Modal in Selenium using WebDriverIO.<\/p>\n<pre class=\"brush:java\">describe(\"This is example of Modal pop up \", function () {\n   it(\"Handle Modal pop up\", function () {\n       browser.url(\"https:\/\/jquerymodal.com\/\");\n       browser.pause(5000);\n       $(\".\/\/a[@href='#ex1']\").click();\n       browser.pause(5000);\n       $(\".\/\/a[@href='#close-modal']\").click();\n   });\n});\n<\/pre>\n<p><a href=\"https:\/\/www.lambdatest.com\/blog\/webdriverio-tutorial-for-handling-dropdown-in-selenium\/\" target=\"_blank\" rel=\"noopener noreferrer\">Also Read: WebDriverIO Tutorial For Handling Dropdown In Selenium<\/a><\/p>\n<h2 class=\"wp-block-heading\">Wrapping It Up!<\/h2>\n<p>In this WebDriverIO tutorial, I shed some light on alert handling in Selenium along with Overlay Modal using WebdriverIO. I also compared alert handling in Selenium using WebDriverIO with other frameworks. I showed how in WebDriverIO you can handle them without switching to them unlike other technologies such as Selenium Java.<\/p>\n<p>Further, I explored the 5 WebDriverIO methods for alert handling in Selenium, these are acceptAlert(), dismissAlert(), getAlertText(), sendAlertText() and isAlertOpen. These methods help to automate Alert pop up but don\u2019t help in handling Overlay Modal. You can access modal\u2019s each and every element so that you can directly use the selector for individual elements and perform the operation. In case you want to know about <a href=\"https:\/\/www.lambdatest.com\/blog\/webdriverio-tutorial-browser-commands-for-selenium-testing\/\" target=\"_blank\" rel=\"noopener noreferrer\">browser commands in WebDriverIO<\/a>, you can refer to the article linked.<\/p>\n<p>I hope you have enjoyed reading this WebDriverIO tutorial on alert handling in Selenium. Feel free to reach out to us in case of any questions or doubts in the comment section down below. <strong>Let\u2019s Automate!!!<\/strong>\ud83d\ude03<\/p>\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/accounts.lambdatest.com\/register\/\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Adword-Cyber2.jpg\" alt=\"\" class=\"wp-image-106386\" width=\"698\" height=\"135\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Adword-Cyber2.jpg 930w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Adword-Cyber2-300x58.jpg 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/Adword-Cyber2-768x149.jpg 768w\" sizes=\"(max-width: 698px) 100vw, 698px\" \/><\/a><\/figure>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Harshit Paul, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">JCG program<\/a>. See the original article here: <a href=\"https:\/\/www.lambdatest.com\/blog\/webdriverio-tutorial-handling-alerts-overlay-in-selenium\/\" target=\"_blank\" rel=\"noopener noreferrer\">WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>You\u2019d hardly find a website these days without alerts and pop-ups! The alert boxes warn you whenever you perform a wrong action or to enter details to access a website. These alert boxes stop you from performing any other browser functions till the alert is resolved. This is why it becomes important that you handle &hellip;<\/p>\n","protected":false},"author":118034,"featured_media":231,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[1321,287,1973],"class_list":["post-106354","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-automation","tag-selenium","tag-webdriverio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about WebDriverIO? Check our article explaining how to handle alerts &amp; pop-ups as well as overlay modal in WebDriverIO\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about WebDriverIO? Check our article explaining how to handle alerts &amp; pop-ups as well as overlay modal in WebDriverIO\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-20T07:00:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Harshit Paul\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Harshit Paul\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html\"},\"author\":{\"name\":\"Harshit Paul\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ab9cba8656b7bc9c554eaff467e478bb\"},\"headline\":\"WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium\",\"datePublished\":\"2020-08-20T07:00:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html\"},\"wordCount\":1240,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"keywords\":[\"Automation\",\"Selenium\",\"WebdriverIO\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html\",\"name\":\"WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"datePublished\":\"2020-08-20T07:00:50+00:00\",\"description\":\"Interested to learn about WebDriverIO? Check our article explaining how to handle alerts & pop-ups as well as overlay modal in WebDriverIO\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/08\\\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ab9cba8656b7bc9c554eaff467e478bb\",\"name\":\"Harshit Paul\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/60038d4bbf107bc2e1159002b3cccd84c66067525181e1389e06b8628b76857b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/60038d4bbf107bc2e1159002b3cccd84c66067525181e1389e06b8628b76857b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/60038d4bbf107bc2e1159002b3cccd84c66067525181e1389e06b8628b76857b?s=96&d=mm&r=g\",\"caption\":\"Harshit Paul\"},\"description\":\"Harshit works as a product growth specialist at LambdaTest. He is also an experienced IT professional, who loves to share his thoughts about the latest tech trends as an enthusiast tech blogger.\",\"sameAs\":[\"https:\\\/\\\/www.lambdatest.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/harshit-paul\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium - Java Code Geeks","description":"Interested to learn about WebDriverIO? Check our article explaining how to handle alerts & pop-ups as well as overlay modal in WebDriverIO","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html","og_locale":"en_US","og_type":"article","og_title":"WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium - Java Code Geeks","og_description":"Interested to learn about WebDriverIO? Check our article explaining how to handle alerts & pop-ups as well as overlay modal in WebDriverIO","og_url":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2020-08-20T07:00:50+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","type":"image\/jpeg"}],"author":"Harshit Paul","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Harshit Paul","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html"},"author":{"name":"Harshit Paul","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ab9cba8656b7bc9c554eaff467e478bb"},"headline":"WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium","datePublished":"2020-08-20T07:00:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html"},"wordCount":1240,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","keywords":["Automation","Selenium","WebdriverIO"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html","url":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html","name":"WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","datePublished":"2020-08-20T07:00:50+00:00","description":"Interested to learn about WebDriverIO? Check our article explaining how to handle alerts & pop-ups as well as overlay modal in WebDriverIO","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2020\/08\/webdriverio-tutorial-handling-alerts-overlay-in-selenium.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"WebDriverIO Tutorial: Handling Alerts &amp; Overlay In Selenium"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ab9cba8656b7bc9c554eaff467e478bb","name":"Harshit Paul","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/60038d4bbf107bc2e1159002b3cccd84c66067525181e1389e06b8628b76857b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/60038d4bbf107bc2e1159002b3cccd84c66067525181e1389e06b8628b76857b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/60038d4bbf107bc2e1159002b3cccd84c66067525181e1389e06b8628b76857b?s=96&d=mm&r=g","caption":"Harshit Paul"},"description":"Harshit works as a product growth specialist at LambdaTest. He is also an experienced IT professional, who loves to share his thoughts about the latest tech trends as an enthusiast tech blogger.","sameAs":["https:\/\/www.lambdatest.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/harshit-paul"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/106354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/118034"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=106354"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/106354\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/231"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=106354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=106354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=106354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}