Am currently using windows handling for opening the map direction in the new window and after it opens i will be closing the child window, which is opened and do the remaming work in the code.But it is closing the whole browser, while debugging it is working correctly , but while running the code, am Getting the error as,
Error - selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
Down i have attached the code,
##Clicking on The Map Image
self.driver.find_element_by_xpath("/html[1]/body[1]/div[1]/div[2]/div[1]/section[1]/div[1]/div[1]/div[2]/div[1]/a[1]/img[1]").click()
##Setting up an Window Handle to get the size.
handels =self.driver.window_handles
size = len(handels)
"""
The Below For Loop, We are using For Handling The Mutilple Windows,
Which are opened in the Browser.
"""
for length in range(size):
driver.switch_to.window(handels[length])
print(self.driver.title)
time.sleep(3)
if length == 1:
driver.close()
Where i have done the error i dunno. please sort me out.