1.) Попробуйте получить WindowHandles () по:
Set<String> windowHandles = driver.getWindowHandles();
Если этот набор имеет 2 значения, вы можете легко переключаться между обоими приложениями с помощью:
driver.switchTo.window(windowHandleOfExcel);
2 .) Если набор содержит только один дескриптор, вам нужно создать новый сеанс рабочего стола для Excel, вы можете сделать то же самое с помощью:
//get a root driver
//all the opened application will be children of this root driver
//get the expected child driver
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("app", "Root");
WindowsDriver rootDriver = new WindowsDriver(new URL("http://127.0.0.1:4723"), cap);
WebElement ele = d.findElementByName("Book - Excel"); //Pass the header or title of the excel opened
String toplevel = ele.getAttribute("NativeWindowHandle");
int x = (Integer.parseInt(toplevel));
toplevel = Integer.toHexString(x);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("appTopLevelWindow", toplevel);
WindowsDriver childdriver = new WindowsDriver(new URL("http://127.0.0.1:4723"), cap);
childDriver - драйвер, указывающий на приложение Excel .
Надеюсь, это поможет.