1

My simple script written in python (selenium) need to click on number of hyperlinks (around 25) in a single web page, each time need to assert something in a new window opened.

I am using the following function to navigate between the windows, which also works well.

def go_window(self, window_name = None):
    if window_name is None:
        self.driver.switch_to_window(self.window_handle)
    else:
        self.driver.switch_to_window(window_name)

However, it does not close the new window opened each time (also because, links in my page open up the new page each time it is clicked :( ).

I would want to close the new window after asserting. Any help would be appreciated. Thanks.

1 Answer 1

1

Use WebDriver.close method, which closes the current window:

self.driver.close()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.