{"id":848,"date":"2019-12-06T12:57:21","date_gmt":"2019-12-06T07:27:21","guid":{"rendered":"http:\/\/http:\/\/artoftesting.com\/\/?p=848"},"modified":"2023-04-27T16:42:21","modified_gmt":"2023-04-27T11:12:21","slug":"wait-for-page-to-load-selenium-webdriver-java","status":"publish","type":"post","link":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java","title":{"rendered":"Wait for Page Load in Selenium"},"content":{"rendered":"\n<p>In this tutorial, we will learn how to <strong>wait for a page to load in Selenium<\/strong> before interacting with the web elements present on that page in order to avoid <strong>NoSuchElementException<\/strong>.<br><br>Before going further into the implementation of wait till page load in Selenium you need to understand the following points-<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An element that triggers page load waits until the DOM gets loaded before returning control to the driver. <br>For example &#8211; if we submit a form by clicking the Submit button then the next statement after the submit button click operation will be attempted by WebDriver only after the page gets loaded completely. So, in most cases, we don&#8217;t even have to wait for the page to load.<br><br><\/li>\n\n\n\n<li>We may have to introduce a wait time when dealing with elements that are ajax based or dynamic elements that load even after the page load.<br><br><\/li>\n\n\n\n<li>In certain cases, we deal with elements that may be visible on page load or after some trigger action but take some time to be available for interaction. <br>For example, a dropdown with dynamic values may be available on the DOM throughout but have its values populated only after we perform some action based on which the corresponding values get dynamically populated. <br>So, in this case, if we try to select a particular value, we must wait for some time for the element to be available for interaction.<br><br><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Wait for the page to load Implementation<\/h2>\n\n\n\n<p>Selenium Webdriver doesn&#8217;t provide any inherent support for wait till page load implementation. But we can make use of\u00a0<strong><a href=\"http:\/\/artoftesting.com\/waits-in-selenium-webdriver#Explicit_Waits\">Explicit Waits<\/a><\/strong>\u00a0to achieve the desired outcome. For this, we need to identify the element on the <a href=\"http:\/\/artoftesting.com\/what-is-a-webpage\">webpage<\/a> that&#8217;s the last one to load or become available for interaction. <br><br>Now, we need to use the explicit wait with the appropriate Expected condition like &#8220;ElementToBeClickable&#8221; for page load implementation. Thus, making sure that the driver waits till all the web elements get loaded successfully before attempting to interact with them.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nWebDriverWait wait = new WebDriverWait(driver, 20);\nwait.until(ExpectedConditions.elementToBeClickable(lastElementToLoad));\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will learn how to wait for a page to load in Selenium before interacting with the web elements present on that page in order to avoid NoSuchElementException. Before going further into the implementation of wait till page load in Selenium you need to understand the following points- Wait for the page &#8230; <a title=\"Wait for Page Load in Selenium\" class=\"read-more\" href=\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java\" aria-label=\"Read more about Wait for Page Load in Selenium\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":1664,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-848","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-selenium"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Wait for Page to Load in Selenium WebDriver with Java<\/title>\n<meta name=\"description\" content=\"Using Explict wait to implement wait for page to load before interacting with the web elements in Selenium Webdriver with Java.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Wait for Page to Load in Selenium WebDriver with Java\" \/>\n<meta property=\"og:description\" content=\"Using Explict wait to implement wait for page to load before interacting with the web elements in Selenium Webdriver with Java.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java\" \/>\n<meta property=\"og:site_name\" content=\"ArtOfTesting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/artoftesting\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-06T07:27:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-27T11:12:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Wait-for-page-load.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"700\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Kuldeep Rana\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@theartoftesting\" \/>\n<meta name=\"twitter:site\" content=\"@theartoftesting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kuldeep Rana\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#article\",\"isPartOf\":{\"@id\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java\"},\"author\":{\"name\":\"Kuldeep Rana\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5\"},\"headline\":\"Wait for Page Load in Selenium\",\"datePublished\":\"2019-12-06T07:27:21+00:00\",\"dateModified\":\"2023-04-27T11:12:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java\"},\"wordCount\":334,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\/\/artoftesting.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#primaryimage\"},\"thumbnailUrl\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Wait-for-page-load.jpg\",\"articleSection\":[\"Selenium\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java\",\"url\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java\",\"name\":\"Wait for Page to Load in Selenium WebDriver with Java\",\"isPartOf\":{\"@id\":\"https:\/\/artoftesting.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#primaryimage\"},\"image\":{\"@id\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#primaryimage\"},\"thumbnailUrl\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Wait-for-page-load.jpg\",\"datePublished\":\"2019-12-06T07:27:21+00:00\",\"dateModified\":\"2023-04-27T11:12:21+00:00\",\"description\":\"Using Explict wait to implement wait for page to load before interacting with the web elements in Selenium Webdriver with Java.\",\"breadcrumb\":{\"@id\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#primaryimage\",\"url\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Wait-for-page-load.jpg\",\"contentUrl\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Wait-for-page-load.jpg\",\"width\":700,\"height\":400,\"caption\":\"wait for page load in selenium\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/artoftesting.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Automation Testing\",\"item\":\"https:\/\/artoftesting.com\/category\/automation-testing\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Selenium\",\"item\":\"https:\/\/artoftesting.com\/category\/automation-testing\/selenium\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Wait for Page Load in Selenium\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/artoftesting.com\/#website\",\"url\":\"https:\/\/artoftesting.com\/\",\"name\":\"ArtOfTesting\",\"description\":\"A Beginners Guide to Testing\",\"publisher\":{\"@id\":\"https:\/\/artoftesting.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/artoftesting.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/artoftesting.com\/#organization\",\"name\":\"ArtOfTesting\",\"url\":\"https:\/\/artoftesting.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png\",\"contentUrl\":\"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png\",\"width\":400,\"height\":60,\"caption\":\"ArtOfTesting\"},\"image\":{\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/artoftesting\",\"https:\/\/x.com\/theartoftesting\",\"https:\/\/www.linkedin.com\/groups\/4797819\/\",\"https:\/\/in.pinterest.com\/artoftesting\/\",\"https:\/\/www.youtube.com\/channel\/UCQ9PUVenvvyrUdDQ9yKn31Q\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5\",\"name\":\"Kuldeep Rana\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g\",\"caption\":\"Kuldeep Rana\"},\"description\":\"Kuldeep is the founder and lead author of ArtOfTesting. He is skilled in test automation, performance testing, big data, and CI-CD. He brings his decade of experience to his current role where he is dedicated to educating the QA professionals.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Wait for Page to Load in Selenium WebDriver with Java","description":"Using Explict wait to implement wait for page to load before interacting with the web elements in Selenium Webdriver with Java.","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:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java","og_locale":"en_US","og_type":"article","og_title":"Wait for Page to Load in Selenium WebDriver with Java","og_description":"Using Explict wait to implement wait for page to load before interacting with the web elements in Selenium Webdriver with Java.","og_url":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java","og_site_name":"ArtOfTesting","article_publisher":"https:\/\/facebook.com\/artoftesting","article_published_time":"2019-12-06T07:27:21+00:00","article_modified_time":"2023-04-27T11:12:21+00:00","og_image":[{"width":700,"height":400,"url":"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Wait-for-page-load.jpg","type":"image\/jpeg"}],"author":"Kuldeep Rana","twitter_card":"summary_large_image","twitter_creator":"@theartoftesting","twitter_site":"@theartoftesting","twitter_misc":{"Written by":"Kuldeep Rana","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#article","isPartOf":{"@id":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java"},"author":{"name":"Kuldeep Rana","@id":"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5"},"headline":"Wait for Page Load in Selenium","datePublished":"2019-12-06T07:27:21+00:00","dateModified":"2023-04-27T11:12:21+00:00","mainEntityOfPage":{"@id":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java"},"wordCount":334,"commentCount":5,"publisher":{"@id":"https:\/\/artoftesting.com\/#organization"},"image":{"@id":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#primaryimage"},"thumbnailUrl":"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Wait-for-page-load.jpg","articleSection":["Selenium"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#respond"]}]},{"@type":"WebPage","@id":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java","url":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java","name":"Wait for Page to Load in Selenium WebDriver with Java","isPartOf":{"@id":"https:\/\/artoftesting.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#primaryimage"},"image":{"@id":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#primaryimage"},"thumbnailUrl":"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Wait-for-page-load.jpg","datePublished":"2019-12-06T07:27:21+00:00","dateModified":"2023-04-27T11:12:21+00:00","description":"Using Explict wait to implement wait for page to load before interacting with the web elements in Selenium Webdriver with Java.","breadcrumb":{"@id":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#primaryimage","url":"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Wait-for-page-load.jpg","contentUrl":"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Wait-for-page-load.jpg","width":700,"height":400,"caption":"wait for page load in selenium"},{"@type":"BreadcrumbList","@id":"https:\/\/artoftesting.com\/wait-for-page-to-load-selenium-webdriver-java#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/artoftesting.com\/"},{"@type":"ListItem","position":2,"name":"Automation Testing","item":"https:\/\/artoftesting.com\/category\/automation-testing"},{"@type":"ListItem","position":3,"name":"Selenium","item":"https:\/\/artoftesting.com\/category\/automation-testing\/selenium"},{"@type":"ListItem","position":4,"name":"Wait for Page Load in Selenium"}]},{"@type":"WebSite","@id":"https:\/\/artoftesting.com\/#website","url":"https:\/\/artoftesting.com\/","name":"ArtOfTesting","description":"A Beginners Guide to Testing","publisher":{"@id":"https:\/\/artoftesting.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/artoftesting.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/artoftesting.com\/#organization","name":"ArtOfTesting","url":"https:\/\/artoftesting.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/","url":"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png","contentUrl":"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png","width":400,"height":60,"caption":"ArtOfTesting"},"image":{"@id":"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/artoftesting","https:\/\/x.com\/theartoftesting","https:\/\/www.linkedin.com\/groups\/4797819\/","https:\/\/in.pinterest.com\/artoftesting\/","https:\/\/www.youtube.com\/channel\/UCQ9PUVenvvyrUdDQ9yKn31Q"]},{"@type":"Person","@id":"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5","name":"Kuldeep Rana","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/artoftesting.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g","caption":"Kuldeep Rana"},"description":"Kuldeep is the founder and lead author of ArtOfTesting. He is skilled in test automation, performance testing, big data, and CI-CD. He brings his decade of experience to his current role where he is dedicated to educating the QA professionals."}]}},"_links":{"self":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts\/848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/comments?post=848"}],"version-history":[{"count":1,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts\/848\/revisions"}],"predecessor-version":[{"id":6784,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts\/848\/revisions\/6784"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/media\/1664"}],"wp:attachment":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/media?parent=848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/categories?post=848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/tags?post=848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}