if (platform != null) {
for (final String p : platform) {
log.info("Platform " + p);
executorService.submit(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
runService(p, config, url, title, report);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
executorService.shutdown();
executorService.awaitTermination(Long.MAX_VALUE,
TimeUnit.NANOSECONDS);
// for(final String p: platform){
// runUIService(p, config, url, title, report);
// }
}
public void runService(){
WebDriver driver = getDriver();
//some selenium operations performed
}
I am trying to execute runService() in multiple threads parallelly. getDriver() method returns a new instance of selenium WebDriver. If I execute for a single platform all the selenium operations run successfully, but if the same code is fired for multiple platforms although a new browser instance is opened for each platform, I am getting a lot of errors on selenium elements not found. I am not able to figure what can be the reason for this ? Is there a problem associated with running multiple browser instances through selenium at the same time ?
I think this is a concurrency issue. Have you tried using synchronized keyword for your method? ie public synchronized void runService()
or in your getDriver() method.
Hope this can help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.