I am not sure which elements will throw this exception.In general is there any method other than providing - a page load time out , implicit, explicit or frequent wait for a particular element .
Depending on the unit test framework which you are using - there are timeout attributes/annotations. E.g.
- [Timeout] in NUnit
- @Test(timeout=1000) in JUnit
In overall it's not a good practice since instead of resolving the root cause of the issue, you'll use the workaround. Your overall test execution time would increase (due to the use of timeouts), while the pass rate would be still low.
Depending on your infrastructure and libraries you're using:
- Plain java: ExecutorService has invokeAll() and invokeAny() functions taking timeout as one of the arguments.
- There is
@Timeableannotation in jcabi-aspects project which limits method execution time to the desired value
- In JUnit there is
timeoutparameter which can be passed to @Test annotation
- In TestNG there is
timeOutparameter which can be passed to @Test annotation