The previous article describes how to start a browser. This article introduces the interface method for wait time in the previous code, the code is as follows:
Driver.manage (). Timeouts (). Pageloadtimeout (5, timeunit.seconds);
The timeout interface has the following three commonly used interfaces.
Implicitlywait (): Implicit time Waits is the time to find the element, set a maximum time value, if the first time driver did not find the page element, then continue to find, until the maximum time value of the setting is consumed, or not found, then throw the exception that did not find the element. If the element is found within the set time range, then the next line of code is executed, and no time is required, which is the meaning of the implicit wait. So, implicit time waits for a common combination of finding page elements together.
Setscripttimeout (), the function is to wait for the execution of an asynchronous script to end, rather than throw an error inside, within the specified time set. This may be used when executing JavaScript scripts.
pageloadtimeout (), the literal meaning of the page load timeout, the role is to set a specified time, waiting for the full loading of the Web page, rather than the inside throw error. We know that if the network speed is slow, or too many page elements, such as a large area of Web page rendering, will certainly cause the page to load slowly. The purpose of this interface is to deal with this kind of problem.
The above is about the wait Time interface method Introduction, Next, I will introduce about the Windows interface.
Java + Selenium Timeout Interface usage Introduction