0

On a button click a popup window appears in internet explorer, which renders a html (given below), I realized this HTML is in update panel, that's I am not able to find any control/elements on it. I am sure with my code, it is switching to child window (popup window), but it is not able to find elements of popup window .

How can I know how to control switch to child window ?

 foreach (String windowHandle in handles)
 {
    if (!windowHandle.Equals(parentWindow))
    {
       objDriver.SwitchTo().Window(windowHandle);
       //trying to find element is always null on popup window
       IWebElement table = objDriver.FindElement(By.TagName("table"));//this is null
       //closing child window, this works fine
       objDriver.Close(); 
     }
  }

Update panel is created like this

<div class="ctl00_updatePanel">
<div class="test">
 <div>
  <table id="tbl">
  <tr>
   <td>
    <a href="#">text 1</a>
   </td>
   <td>
  <tr>
  <tr>
   <td>
    <a href="#">text 2</a>
   </td>
   <td>
  <tr>    
  </table>
 </div>
</div>
</div>

When I try to find any control in this window it always says element not found and it breaks.

I have already added the to wait for an element to load but it still breaks saying element not found, though element is loaded properly in child window.

Var
  • 217
  • 5
  • 16
  • http://selenium-webdrive-java.blogspot.com/2019/01/handle-multiple-window-in-selenium.html – Dhru 'soni Apr 24 '19 at 12:30
  • @Dhru'soni it shows how to switch to window. But I already did that part, my problem is after switching I am not able to find elements on that window – Var Apr 24 '19 at 12:39
  • can you post the html and also mentioned your expected output – KunduK Apr 24 '19 at 12:45
  • @KunduK I have updated the HTML, all the above HTML is dynamically created. I want to access the table in dynamically created div – Var Apr 24 '19 at 14:29
  • Is there are some other windows than your parent and child? If yes than it can cause this issue. For testing purpose, you can put some control outside update panel to check whether you are able to access it or not. For testing purpose, try to access table with its ID. you can try to wait for some more time till the dynamic content get generated. – Deepak-MSFT Apr 25 '19 at 05:35
  • @Deepak-MSFT 1) wait.until() is already tested, but still not working. 2) All the elements which are outside the update panel are accessible. – Var Apr 25 '19 at 10:06
  • It can be possible that elements inside an update panel are inaccessible using web driver. If that site is developed by you than you can also check the settings for your update panel. – Deepak-MSFT Apr 30 '19 at 08:25

0 Answers0