需要在多线程环境中实现WebDriver,以便我的每个测试用例在并行执行时都会启动自己的线程。尝试了ThreadLocal
概念,但没有解决问题。由于元素不可见和超时异常,测试用例随机失败。
我会说不要自己管理线程,因为这并不容易,而且很难管理。而是使用像testNG这样的框架
TestNG 支持在类/方法/测试级别使用多个线程并行执行
<suite name="My suite" parallel="methods" thread-count="5">
<suite name="My suite" parallel="tests" thread-count="5">
<suite name="My suite" parallel="classes" thread-count="5">
<suite name="My suite" parallel="instances" thread-count="5">