SeleniumBase/examples/rate_limiting_test.py

21 lines
629 B
Python
Raw Normal View History

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
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):
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)
for item in range(1, 11):
2015-12-05 05:11:53 +08:00
self.print_item(item)