0

I am using Edge with IE compatibility (IEDriverServer) with Selenium and Java. At a certain point I do a click, and a new window opens. When I do this locally from my machine, driver.getWindowHandles() will show the new window (2 windows), but when I do this on the Selenium grid, only one window shows (the original) and it cannot find the new HMTL. The setup (IEdriverServer options etc) are the same. The only difference is the machine on which it is running (and running remotely). My guess is on the remote machine the new Window may be on a different machine as there are two, the grid machine and the display machine?

Edge: Version 116.0.1938.54 (Official build) (64-bit)
IEDriverServer: 4.10.0.0

Here is a bit of code sample:

 String xp = "//a[@id='iframe_DocList']";
 WebElement view driver.findElement(By.xpath(xp));
 // We have a check to verify view is not empty
 view.click();
 try {
        Thread.sleep(10000);
 } catch (InterruptedException e) {

 }

 // Here is where I find the window.  Locally driver.getWindowHandles() has 2 windows/
 // On grid there is just 1
 for (int i = 0; i < 2 && !found; i++) {
    for (String d : driver.getWindowHandles()) {
        driver.switchTo().window(d);
        // the new window should have an iframe 'DocSelectPage'
        if (driver.findElements(By.xpath("//iframe[@id='DocSelectPage']").size()) !=0) {
            found = true;
            break;
        }
    }
}

a cross-section of the HTML:

 <td><a onclick="return onclick_DocType();" id="iframe_DocList" 
     class="fauxButton" style="WIDTH: 108px; 
     PADDING-BOTTOM: 2px; PADDING-TOP: 2px; PADDING-LEFT: 8px; 
     PADDING-RIGHT: 8px" href="" target="_blank">View Documents</a>
 </td>

 
Tony
  • 1,127
  • 1
  • 18
  • 29
  • According to your description, the code works fine locally with Selenium, but it doesn't work correctly with Selenium grid? I simply checked the code you provided, and I found that it should open a new window through this code: `view.click();`, but it seems to be executed only once, how to open two windows in this case? – Xudong Peng Aug 23 '23 at 08:06
  • it opens 1 and there was already 1 open so there are a total of 2 – Tony Aug 23 '23 at 10:15
  • Do you mean this code `view.click()` won't open new window using selenium grid on the remote machine? Unfortunately, I don't have enough environment to reproduce this problem, have you tried to narrow down the problem? For example, check whether the `WebElement view` is correctly acquired through a breakpoint? – Xudong Peng Aug 24 '23 at 07:12
  • I have tried everything. What I think it is. First it opens it in a new tab, but then when it createzs and opens the .aspx file, it separates the TAB into a new window and must be doing it on the master machine? – Tony Aug 28 '23 at 10:14

0 Answers0