{"id":6764,"date":"2023-05-18T04:43:48","date_gmt":"2023-05-18T04:43:48","guid":{"rendered":"https:\/\/studysection.com\/blog\/?p=6764"},"modified":"2023-10-17T07:22:48","modified_gmt":"2023-10-17T07:22:48","slug":"wait-methods-in-selenium","status":"publish","type":"post","link":"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/","title":{"rendered":"Wait Methods in Selenium"},"content":{"rendered":"<p>Wait Methods are a group of methods that pause between execution statements. They&#8217;re beneficial for AJAX applications. AJAX stands for Asynchronous JavaScript. It is an XML which is a technique for designing asynchronous applications. This kind of application does not have to reload the web page while exchanging data with a server and updating parts of the web page. As a result, when a browser loads a web page, the WebElements may load at different time intervals. If a WebElement is not identified by a specific time, an exception will cause the Test Script to fail. Nevertheless, an automation engineer can avoid this problem using Wait Methods but the most utilized methods are Implicit Wait and Explicit Wait.<\/p>\n<h2>Implicit Wait<\/h2>\n<p>An Implicit Wait Method is used to implement a default waiting time for each Test Step within the entire Test Script. While waiting, WebDriver continues polling the Document Object Model (DOM) for the WebElement. If the WebElement is placed before the default time then the next Test Step is executed. However, if the WebElement isn\u2019t located within the specified time then an exception shows up. The below-given screenshots display a description and syntax for Implicit Wait.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/05\/Selenium2-2.png\" alt=\"\" \/><\/p>\n<p><strong>Screenshot 01: Above screenshot shows the Implicit Wait Syntax and Description<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/05\/Selenium3.png\" alt=\"\" \/><\/p>\n<p><strong>Screenshot 02: Above screenshot shows the Implicit Wait 5 Seconds<\/strong><br \/>\nImplicit wait accepts the below given 2 parameters:<\/p>\n<ol>\n<li>time &#8211; accepts the time as an integer value<\/li>\n<li>unit &#8211; accepts the time measurement in terms of SECONDS, NANOSECONDS, MINUTES, MILLISECONDS, MICROSECONDS, HOURS, and DAYS<\/li>\n<\/ol>\n<p><strong>Note:<\/strong> Usually, an Implicit Wait Method is provided before loading the web page within the setUp() method<\/p>\n<h2>Explicit Wait<\/h2>\n<p>Explicit Wait Methods are used to interrupt execution until time has elapsed or an expected condition is met. That condition must be satisfied before moving to the next Test Step. Selenium WebDrvier offers a WebDriverWait class and an ExpectedConditions class to assist Explicit Wait. It\u2019s important to know that Explicit Waits are limited to a specific WebElement.<\/p>\n<p>The WebDriverWait class creates an object reference and uses an instance of WebDriver. Also, a maximum number of seconds is added for execution inactivity. If the WebElement isn\u2019t found then an exception is thrown. The below-given screenshot shows a description and syntax for WebDriverWait:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/05\/Selenium2-1.png\" alt=\"web driver\" width=\"778\" height=\"264\" \/><\/p>\n<p><strong>Screenshot 03: Above screenshot shows the WebDriverWait Syntax and Description<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/05\/Selenium5.png\" alt=\"web driver wait\" width=\"773\" height=\"307\" \/><\/p>\n<p><strong>Screenshot 04: Above screenshot shows the WebDriverWait- TimeOut In 5 seconds<\/strong><br \/>\nIn the above example, an object reference of wait is created for WebDriverWait while the driver is the reference object for WebDriver. A maximum of 5 seconds is provided to locate the WebElement. Afterward, an automation engineer has to inform WebDriver to wait until an expected condition is met. The ExpectedConditons class supplies many methods for using these scenarios that may occur before executing the next Test Step. Here\u2019s a screenshot that displays a few ExpectedConditions methods.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/05\/Selenium4.png\" alt=\"timeout\" width=\"777\" height=\"227\" \/><\/p>\n<p><strong>Screenshot 05: Above screenshot shows the Methods via ExpectedConditions Class<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/05\/Selenium1-2.png\" alt=\"\" \/><\/p>\n<p><strong>Screenshot 06: Above screenshot shows the ExpectedConditions Example<\/strong><br \/>\nThe ExpectedConditions class is accessed after writing the WebDriverWait reference \u201cwait, dot operator, then until() method. Subsequently, many methods are available when writing dot after ExpectedConditions. The above statements look ahead to whichever happens first: wait for seconds or until the element is clickable. In alphabetical order, below given is a list of additional methods that are not shown in the screenshot<\/p>\n<ol>\n<li>alertIsPresent()<\/li>\n<li>elementSelectionsStateToBe()<\/li>\n<li>elementToBeClickable()<\/li>\n<li>invisibilityOfTheElementLocated()<\/li>\n<li>invisibilityOfTheElementWithText()<\/li>\n<li>presenceOfAllElementsLocatedBy()<\/li>\n<li>presenceOfElementLocated()<\/li>\n<li>textToBePresentInElement()<\/li>\n<li>textToBePresentInElementLocated()<\/li>\n<li>textToBePresentInElementValue()<\/li>\n<li>titleIs()<\/li>\n<li>titleContains()<\/li>\n<li>visibilityOf()<\/li>\n<li>visibilityOfAllElements()<\/li>\n<li>visibilityOfAllElementsLocatedBy()<\/li>\n<li>visibilityOfElementLocated()<\/li>\n<\/ol>\n<p><strong>The following is a table summarizing Implicit and Explicit Wait:<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/05\/Selenium6.png\" alt=\"wait methods\" width=\"775\" height=\"195\" \/><\/p>\n<p><small><em>People having good knowledge of Financial accounting can get an <a href=\"https:\/\/www.studysection.com\/financial-accountant-advanced-diploma\">Accounting Certification Exams<\/a> from StudySection to increase their chances of getting a job in this field. You can get a foundation level certification if you are new to Financial accounting or you can go for advanced level certification if you have expert level skills in Financial accounting.<\/em><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wait Methods are a group of methods that pause between execution statements. They&#8217;re beneficial for AJAX applications. AJAX stands for<\/p>\n","protected":false},"author":1,"featured_media":6765,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[124,22],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Wait Methods in Selenium - StudySection Blog<\/title>\n<meta name=\"description\" content=\"Selenium WebDrvier offers a WebDriverWait class and an ExpectedConditions class to assist Explicit Wait.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Wait Methods in Selenium - StudySection Blog\" \/>\n<meta property=\"og:description\" content=\"Selenium WebDrvier offers a WebDriverWait class and an ExpectedConditions class to assist Explicit Wait.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Posts on famous people, innovations and educational topics\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/studysection\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-18T04:43:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-17T07:22:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/05\/Selenium1-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin-studysection-blog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@studysection\" \/>\n<meta name=\"twitter:site\" content=\"@studysection\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-studysection-blog\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/\"},\"author\":{\"name\":\"admin-studysection-blog\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\"},\"headline\":\"Wait Methods in Selenium\",\"datePublished\":\"2023-05-18T04:43:48+00:00\",\"dateModified\":\"2023-10-17T07:22:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/\"},\"wordCount\":630,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"keywords\":[\"selenium\",\"testing\"],\"articleSection\":[\"Learn and Grow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/\",\"url\":\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/\",\"name\":\"Wait Methods in Selenium - StudySection Blog\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/#website\"},\"datePublished\":\"2023-05-18T04:43:48+00:00\",\"dateModified\":\"2023-10-17T07:22:48+00:00\",\"description\":\"Selenium WebDrvier offers a WebDriverWait class and an ExpectedConditions class to assist Explicit Wait.\",\"breadcrumb\":{\"@id\":\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/studysection.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Wait Methods in Selenium\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/studysection.com\/blog\/#website\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"name\":\"Blog Posts on famous people, innovations and educational topics\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/studysection.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/studysection.com\/blog\/#organization\",\"name\":\"StudySection\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"contentUrl\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"width\":920,\"height\":440,\"caption\":\"StudySection\"},\"image\":{\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/studysection\",\"https:\/\/twitter.com\/studysection\",\"https:\/\/www.instagram.com\/study.section\/\",\"https:\/\/www.linkedin.com\/company\/studysection\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\",\"name\":\"admin-studysection-blog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"caption\":\"admin-studysection-blog\"},\"url\":\"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Wait Methods in Selenium - StudySection Blog","description":"Selenium WebDrvier offers a WebDriverWait class and an ExpectedConditions class to assist Explicit Wait.","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:\/\/studysection.com\/blog\/wait-methods-in-selenium\/","og_locale":"en_US","og_type":"article","og_title":"Wait Methods in Selenium - StudySection Blog","og_description":"Selenium WebDrvier offers a WebDriverWait class and an ExpectedConditions class to assist Explicit Wait.","og_url":"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/","og_site_name":"Blog Posts on famous people, innovations and educational topics","article_publisher":"https:\/\/www.facebook.com\/studysection","article_published_time":"2023-05-18T04:43:48+00:00","article_modified_time":"2023-10-17T07:22:48+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/05\/Selenium1-1.png","type":"image\/png"}],"author":"admin-studysection-blog","twitter_card":"summary_large_image","twitter_creator":"@studysection","twitter_site":"@studysection","twitter_misc":{"Written by":"admin-studysection-blog","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/#article","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/"},"author":{"name":"admin-studysection-blog","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402"},"headline":"Wait Methods in Selenium","datePublished":"2023-05-18T04:43:48+00:00","dateModified":"2023-10-17T07:22:48+00:00","mainEntityOfPage":{"@id":"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/"},"wordCount":630,"commentCount":0,"publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"keywords":["selenium","testing"],"articleSection":["Learn and Grow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/","url":"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/","name":"Wait Methods in Selenium - StudySection Blog","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/#website"},"datePublished":"2023-05-18T04:43:48+00:00","dateModified":"2023-10-17T07:22:48+00:00","description":"Selenium WebDrvier offers a WebDriverWait class and an ExpectedConditions class to assist Explicit Wait.","breadcrumb":{"@id":"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/studysection.com\/blog\/wait-methods-in-selenium\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/studysection.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Wait Methods in Selenium"}]},{"@type":"WebSite","@id":"https:\/\/studysection.com\/blog\/#website","url":"https:\/\/studysection.com\/blog\/","name":"Blog Posts on famous people, innovations and educational topics","description":"","publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/studysection.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/studysection.com\/blog\/#organization","name":"StudySection","url":"https:\/\/studysection.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","contentUrl":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","width":920,"height":440,"caption":"StudySection"},"image":{"@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/studysection","https:\/\/twitter.com\/studysection","https:\/\/www.instagram.com\/study.section\/","https:\/\/www.linkedin.com\/company\/studysection"]},{"@type":"Person","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402","name":"admin-studysection-blog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","caption":"admin-studysection-blog"},"url":"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/"}]}},"views":157,"_links":{"self":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6764"}],"collection":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/comments?post=6764"}],"version-history":[{"count":13,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6764\/revisions"}],"predecessor-version":[{"id":7102,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6764\/revisions\/7102"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media\/6765"}],"wp:attachment":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media?parent=6764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/categories?post=6764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/tags?post=6764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}