问题描述
我已经在这个自动化项目上工作了 2 年,现在我正在尝试使用 ThreadLocal 实现并行测试。我对此进行了大量研究,并且已经实现了 ThreadLocal driver = new ThreadLocal();在我的 BaseTestClass 中。我的问题是我正在使用页面对象模型,其中每个页面都是一个带有对象的类。 Eclipse 说将构造函数更改为
public LoginlogoutPage(ThreadLocal<WebDriver> driver) {
this.driver = driver;
}
我这样做了,然后系统会提示我更改 WebDriver 驱动程序;到 ThreadLocal 驱动程序。在我这样做之后,我所有流畅的等待下面都有一条红线说
"The constructor FluentWait<WebDriver>(ThreadLocal<WebDriver>) is undefined"
public class BaseTestCriticalScenarios {
protected static ThreadLocal<WebDriver> driver = new ThreadLocal<>();
@BeforeClass
public void setUp() throws InterruptedException,MalformedURLException {
// --------Extent Report--------
report = ExtentManager.getInstance();
// -----------------------------
System.setProperty("webdriver.chrome.driver","C:\\GRID\\chromedriver.exe");
ChromeOptions option = new ChromeOptions();
// --https://stackoverflow.com/questions/43143014/chrome-is-being-controlled-by-automated-test-software
option.setExperimentalOption("useAutomationExtension",false);
option.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));
// --https://stackoverflow.com/questions/56311000/how-can-i-disable-save-password-popup-in-selenium
option.addArguments("--disable-features=VizdisplayCompositor");
option.addArguments("--start-maximized");
option.addArguments("--disable-gpu");
Map<String,Object> prefs = new HashMap<String,Object>();
prefs.put("credentials_enable_service",false);
prefs.put("profile.password_manager_enabled",false);
option.setExperimentalOption("prefs",prefs);
System.out.println(System.getenv("BUILD_NUMBER"));
String env = System.getProperty("BUILD_NUMBER");
if (env == null) {
DesiredCapabilities capability = DesiredCapabilities.chrome();
capability.setCapability(CapabilityType.broWSER_NAME,"Chrome");
capability.setCapability(ChromeOptions.CAPABILITY,option);
option.merge(capability);
driver.set(new RemoteWebDriver(new URL(COMPLETE_NODE_URL),capability));
getDriver().get(HOME_PAGE);
getDriver().manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
} else {
driver.set(new ChromeDriver(option));
getDriver().manage().window().maximize();
getDriver().get(HOME_PAGE);
getDriver().manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
}
}
public WebDriver getDriver() {
//Get driver from ThreadLocalmap
return driver.get();
}
下面是我的页面对象类
任何帮助将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)