I have already tried that but I do get below exception if i try to interact with browser -
Exception in thread "main" org.openqa.selenium.InvalidElementStateException: invalid element state
package gridTest;
import java.io.File;
import java.util.Hashtable;
import java.util.Map;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class TwoBrowserTeset {
public static void main(String[] args) throws InterruptedException {
//chrome configuration started
File file = new File(System.getProperty("user.dir") + "\\src\\setupEnv\\" +"chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
//System.setProperty("Always.ask.where.to.save.files", true);
Map<String, String> prefs = new Hashtable<String, String>();
prefs.put("download.prompt_for_download", "true");
prefs.put("download.default_directory", "C:\\");
prefs.put("download.extensions_to_open", "pdf");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.prefs", prefs);
WebDriver wb1= new ChromeDriver(capabilities);
//done for chrome
File fileIE = new File(System.getProperty("user.dir") + "\\src\\setupEnv\\" +"IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", fileIE.getAbsolutePath());
DesiredCapabilities capsIE = DesiredCapabilities.internetExplorer();
capsIE.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
capsIE.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
WebDriver wb2 = new InternetExplorerDriver(capsIE);
//open site in Chrome
wb1.manage().window().maximize();
//String ChromeWindowHandle = wb1.getWindowHandle();
Thread.sleep(30);
//open site in IE
//String IEWindowHandle = wb2.getWindowHandle();
Thread.sleep(30);
//do operations on Chrome
wb1.findElement(By.xpath("//*[@id='gs_htif0']")).sendKeys("selenium");
Thread.sleep(10);
Thread.sleep(30);
Thread.sleep(30);
wb2.findElement(By.xpath("//*[@id='alertexamples']")).click();
wb2.switchTo().alert().accept();
wb2.close();
wb1.close();
}
}