硒蟒蛇做每10秒测试 [英] Selenium python do test every 10 seconds
本文介绍了硒蟒蛇做每10秒测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用硒(Python)的测试和我需要测试我的应用程序每10秒自动完成。
I am using selenium (python) testing and I need to test my application automatically every 10 seconds.
我怎样才能做到这一点?
How can I do this?
推荐答案
您可以使用的 threading.Timer :
import threading
import logging
def print_timer(count):
if count:
t = threading.Timer(10.0, print_timer,args=[count-1])
t.start()
logger.info("Begin print_timer".format(c=count))
time.sleep(15)
logger.info("End print_timer".format(c=count))
def using_timer():
t = threading.Timer(0.0, print_timer,args=[3])
t.start()
if __name__=='__main__':
logging.basicConfig(level=logging.DEBUG,
format='%(threadName)s: %(asctime)s: %(message)s',
datefmt='%H:%M:%S')
using_timer()
收益
Thread-1: 06:46:18: Begin print_timer --
| 10 seconds
Thread-2: 06:46:28: Begin print_timer --
Thread-1: 06:46:33: End print_timer | 10 seconds
Thread-3: 06:46:38: Begin print_timer --
Thread-2: 06:46:43: End print_timer | 10 seconds
Thread-4: 06:46:48: Begin print_timer --
Thread-3: 06:46:53: End print_timer
Thread-4: 06:47:03: End print_timer
请注意,这将产生一个新的线程永远10秒。一定要提供一些方法线程产卵停止之前的线程的数量变得不可容忍。
Note that this will spawn a new thread ever 10 seconds. Be sure to provide some way for the thread-spawning to cease before the number of threads becomes intolerable.
这篇关于硒蟒蛇做每10秒测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文