I have a JavaFX button which executes following code (simplified)
Task<List<PubListEntry>> theTask = new Task<List<PubListEntry>>() {
@Override
protected List<PubListEntry> call() {
dh = (DataHandler) selectedSource.getSourceClass().newInstance();
return dh.extractInformation(...);
}
};
Thread t= new Thread(theTask );
t.start();
It will create a new instance of a class depending of a selected entry of a ComboBox and then calls a method. In one of the classes I want to use Selenium to control a browser window.
public class Source1 implements DataHandler {
public Source1 () {
Browser.start();
}
@Override
public List<PubListEntry> extractInformation(...) {...}
}
And the static method start
look like this.
static void start() {
if (driver == null) {
driver = new ChromeDriver();
driver.manage().window().maximize();
}
}
But the task will fail if I instantiate Source1
. So I think it has something to do with Selenium, but I can't figure it out what it is. Previously the Browser
class was an abstract class and I had to extend Source1
. Everything worked well with as an abstract class. Now I prefer if it would be an independent class. Does anybody have an idea why the Thread/Task ist failing?