3 waiting methods, let you learn how to set up automated waiting test scripts in Selenium!

1. Why does the Selenium script need to set the waiting mode? ——That is, what is his application background?

When using Selenium, the corresponding page elements cannot be displayed immediately during the browser loading process and element operations cannot be performed. A certain waiting time needs to be set to wait for the elements to appear. (To put it simply, it means setting a waiting time for the page elements to be loaded before the elements can be operated)

2. What is Selenium’s waiting method? How to write automated waiting scripts?

Selenium has 3 waiting methods.

1. Forced to wait for sleep

Set the approximate waiting sleep time. Regardless of whether the element is found or not, you must wait for the set sleep time to end.

2. Display waiting

A relatively smart waiting method , you can decide whether to terminate waiting by setting whether the waiting condition is met .

If the waiting element is found during the waiting time, the waiting can be terminated early; if the page element has not been found after the waiting time has elapsed, an exception will be thrown.

3. Implicit waiting

Use the implicitly_wait() method to set the waiting time . If an element is found during the waiting time, the waiting can be ended early. If the element is still not found after the waiting time, an exception will be thrown.

 Finally, I would like to thank everyone who reads my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, if you can use it, you can take it directly:

How to obtain documents:

This document should be the most comprehensive and complete preparation warehouse for friends who want to engage in [software testing]. This warehouse has also accompanied me through the most difficult journey. I hope it can also help you!

All of the above can be shared. You only need to search the vx official account: Programmer Hugo to get it for free.

Guess you like

Origin blog.csdn.net/2301_79535544/article/details/133533270