我在Selenium Grid中運行代碼。 我有一個名爲TestBase的類,如下所示,我想退出所有線程,當我點擊一個按鈕,但是當我點擊按鈕時拋出一個NullpointerException。如何殺死Selenium Grid節點中的線程
public class TestBase {
protected ThreadLocal<RemoteWebDriver> threadDriver = null;
Button b;
Frame f;
static boolean flag = true;
@BeforeMethod
public void setUp() throws MalformedURLException {
if(flag)
{
JFrame calcFrame = new JFrame();
flag = false;
calcFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JButton button1 = new JButton("1");
button1.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent ae) {closure();}
});
calcFrame.add(button1);
calcFrame.setVisible(true);
}
threadDriver = new ThreadLocal<RemoteWebDriver>();
DesiredCapabilities dc = new DesiredCapabilities();
FirefoxProfile fp = new FirefoxProfile();
dc.setCapability(FirefoxDriver.PROFILE, fp);
dc.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
threadDriver.set(new RemoteWebDriver(new URL("http://192.168.3.7:4444/wd/hub"), dc));
}
public WebDriver getDriver() {
return threadDriver.get();
}
public void closure()
{
getDriver().quit();
}
@AfterMethod
public void closeBrowser() {
// log.info("In closeBrowser...");
getDriver().quit();
}
}
我想它無法找到它必須退出的線程。請幫助.. :)
提供堆棧跟蹤 –
非常感謝Alexei表現出的興趣,但我明白我的錯誤n解決了它... 但真的很感謝噸..! :) – LeonarD
我只需要在創建線程後包含框架代碼..這樣我就可以跟蹤每個線程seperatly ..:P – LeonarD