-1

I am not able to identify the modal dialog box in an application run on IE browser using selenium java. I am getting a null pointer exception. I tried all possible ways. I wanted to know if there is any bug in that issue?

Dev
  • 2,739
  • 2
  • 21
  • 34
Mia
  • 3
  • 1

1 Answers1

0

Do you mean you are not able to switch to modal dialog? If yes than you can refer line of code below may help you to switch to modal dialog from parent window.

 String parentWindowHandler = driver.getWindowHandle(); // Store your parent window
String subWindowHandler = null;

Set<String> handles = driver.getWindowHandles(); // get all window handles
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
    subWindowHandler = iterator.next();
}
driver.switchTo().window(subWindowHandler); // switch to popup window

// Now you are in the popup window, perform necessary actions here

driver.switchTo().window(parentWindowHandler);  // switch back to parent window

Reference:

How to handle Pop-up in Selenium WebDriver using Java

If I misunderstood anything from your above description than try to provide detailed description about your issue with sample code. We will again try to check the issue and try to provide suggestions for it.

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19
  • Yea i wanted to switch to modal dialog from the parent window. I tried even this code but still giving me a null pointer error. So the scenario is when I clicked this button it gives a modal dialog box where when I try to switch the driver immediately it is giving me null pointer. I am not sure where the mistake is.. – Mia May 29 '19 at 13:22
  • Can you please inform us, which version of IE you are using for testing? If you are using any older version than try to make a test with IE 11. If you are using IE 11 than try to make a test on any other machine with IE 11 to check the result. If possible than I suggest you to post your sample code here. So that community member can see what you are doing in your code. Which may help to narrow down the issue. – Deepak-MSFT May 30 '19 at 01:04