Reputation: 309
This error happen when i try execute this looping:
Robot robox = new Robot();
WebDriver driver = new FirefoxDriver();
//LINKS
String[] l = new String[3];
l[0] = "http://www.google.com";
l[1] = "http://www.wallmart.com";
l[2] = "http://www.google.com";
for(int i = 0; i < l.length; i++){
driver.get(l[i]);
driver.manage().window().maximize();;
robox.keyPress(KeyEvent.VK_ALT);
robox.keyPress(KeyEvent.VK_F4);
robox.keyRelease(KeyEvent.VK_ALT);
robox.keyRelease(KeyEvent.VK_F4);
}
I have read this may happen because I close the browser, but don't know how solve this.
ERROR
Exception in thread "AWT-EventQueue-0"
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the
remote browser. It may have died.
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:15:02'
System info: host: 'My-PC', ip: '10.0.0.50', os.name: 'Windows 7', os.arch: 'x86',
os.version: '6.1', java.version: '1.7.0_45'
Upvotes: 1
Views: 657
Reputation: 14748
Just read what you are trying to do in human language:
1. Open new Firefox window
2. Type "www.google.com" into Firefox adress bar and press Enter
3. Close Firefox
4. Type "http://www.wallmart.com" into Firefox adress bar and press Enter
At step 4 you must say to yourself: "Wait, what? But I did close it!" And thats what I feel the error is about. so to fix it I would propose adding driver = new FirefoxDriver();
at the end of the loop:
for(int i = 0; i < l.length; i++){
driver.get(l[i]);
driver.manage().window().maximize();;
robox.keyPress(KeyEvent.VK_ALT);
robox.keyPress(KeyEvent.VK_F4);
robox.keyRelease(KeyEvent.VK_ALT);
robox.keyRelease(KeyEvent.VK_F4);
driver = new FirefoxDriver();
}
anyway, did you know that for closing the window you can also just call driver.close();
and it will do exactly the same as you do by using Robot?
Upvotes: 1