2017-04-23 11:26:50 +08:00
|
|
|
"""
|
|
|
|
This test demonstrates the use of the "rate_limited" decorator.
|
|
|
|
You can use this decorator on any method to rate-limit it.
|
|
|
|
"""
|
|
|
|
|
2020-12-18 14:25:31 +08:00
|
|
|
from seleniumbase import BaseCase
|
2018-03-04 08:09:18 +08:00
|
|
|
from seleniumbase import decorators
|
2015-12-05 05:11:53 +08:00
|
|
|
|
|
|
|
|
2021-03-11 06:27:52 +08:00
|
|
|
class RateLimitingTests(BaseCase):
|
2020-12-18 14:25:31 +08:00
|
|
|
@decorators.rate_limited(4.2) # The arg is max calls per second
|
2015-12-05 05:11:53 +08:00
|
|
|
def print_item(self, item):
|
2016-06-26 02:30:31 +08:00
|
|
|
print(item)
|
2015-12-05 05:11:53 +08:00
|
|
|
|
|
|
|
def test_rate_limited_printing(self):
|
2020-12-18 14:25:31 +08:00
|
|
|
message = "Running rate-limited print() on the command line"
|
|
|
|
self.open("data:text/html,<p>%s</p>" % message)
|
|
|
|
print("\n%s:" % message)
|
2017-07-20 06:38:55 +08:00
|
|
|
for item in range(1, 11):
|
2015-12-05 05:11:53 +08:00
|
|
|
self.print_item(item)
|