Switch To Web Dialog Box In Selenium Webdriver: Python
I want to handle a web dialog box under selenium web driver (Internet Explorer) . I am using Python In my application when I click on Icon, a web dialog box opens which contains so
Solution 1:
Try this:
parent_h = browser.current_window_handle
# click on the link that opens a new window
handles = browser.window_handles # before the pop-up window closes
handles.remove(parent_h)
browser.switch_to_window(handles.pop())
# do stuff in the popup# popup window closes
browser.switch_to_window(parent_h)
# and you're back
Solution 2:
I think the problem is with the following code -
driver.switch_to_alert();
You want to switch to another dialog box which appears when you perform the first click() operation. I think that this box that appears is not an alert. You might have to switch to the other dialog box by using
driver.getWindowHandles();
driver.switchTo().window(handle);
You can check an example here.
Post a Comment for "Switch To Web Dialog Box In Selenium Webdriver: Python"