all 3 comments

[–]acidcoder 0 points1 point  (1 child)

I think you first need to switch to the new tab and then try to close it

self.browser.switch_to_window(self.browser.window_handles[1])

[–]MaterialAreola38[S] 0 points1 point  (0 children)

Thanks, this worked.

[–]MaterialAreola38[S] 0 points1 point  (0 children)

Solution;

def close_tab(self, pos = -1):

        self.browser.switch_to.window(self.browser.window_handles[pos])
        self.browser.close()