How to open url in IE tabs and not in new windows - Java

I'm a little noob, so please carry me. I am trying to open many URLs in Internet Explorer right away. About 40 URLs.

I have an array of my urls and I use the following code:

for (int i = 0; i < urls.length; i++){ java.awt.Desktop.getDesktop().browse(java.net.URI.create(urls[i])); } 

This works fine if I already have IE open. However, if it does not open, it creates 40 new windows, not tabs. I tried to get around this using the following:

 for (int i = 0; i <= 9; i++){ java.awt.Desktop.getDesktop().browse(java.net.URI.create(urls[i])); try { Thread.currentThread().sleep(200); } catch (InterruptedException ex) { Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex); } } 
+6
source share
2 answers

200 is too small, I tried 1000, and it was too small too, but 2000 was fine. And of course, open the first one, then wait, and then immediately open all the others.

+2
source

You can make your first call, then grab a list of running processes and wait until iexplore appears, and then continue with the rest. Or, of course, wait longer

This seems to have a way to get running processes.

+1
source

Source: https://habr.com/ru/post/899780/


All Articles