【发布时间】:2022-01-21 18:47:32
【问题描述】:
我喜欢在很多线程中测试我的网站。但是当我尝试这样做时,我发现了一个问题。我喜欢的所有动作都发生在最后打开的窗口中。所以,第一个窗口只是卡在后台。
public class Core extends Thread{
private static FirefoxDriver firefoxDriver;
public Core(){
firefoxDriver = new FirefoxDriver();
}
@Override
public void run() {
firefoxDriver.get("https://google.com/");
firefoxDriver.close();
}
}
public class Main {
public static void main(String[] args) throws AWTException {
System.setProperty("webdriver.gecko.driver", "/home/riki/Downloads/geckodriver-v0.30.0-linux64/geckodriver");
Core core = new Core();
Core core2 = new Core();
core.start(); // This thread is stuck in back
core2.start(); // This thread goes to google.com twice
}
}
我真的不明白为什么会这样。你可以看到它here。在代码运行之后,第一个窗口一直挂在后面。它不关闭。当执行代码后第二个线程关闭时
【问题讨论】:
标签: java selenium selenium-webdriver selenium-firefoxdriver java-threads