L
L
lok1012022-03-05 14:27:14
Python
lok101, 2022-03-05 14:27:14

Webdriver Chrome does not close the browser. What is the reason?

I am writing a bot for instagram and the browser window stopped closing on command in one particular place in the code. This happened after a few changes, before everything worked. At what exact moment this happened, I did not trace.

Since the code is scattered over the methods, I don’t know how to correctly transfer it here, here is a link to the repository .

And here is the section of code to which the window is not closed (main.py file):

class StartBot(FunctionClass):
    def start(self):
        try:
            self.parameter_input()
            self.browser_parameter()
            eval(f'self.start_{self.working_mode}()')

        finally:
            if self.browser is not None:
                self.browser.quit()


Previously, it worked like this: when the task was completed or manually interrupted, the browser window was closed. This is what I want to achieve. The problem is that for the second day I can not find the reason why it ignores the command to close the browser.
When viewing in debug mode, after interrupting the task manually, the program reaches the line containing the command to close the browser, hangs on this command for 20-25 seconds and writes "KeyboardInterrupt" to the console, while not closing the browser window. At the same time, if you put a command to close the browser, for example, after opening it, then everything works and I can’t understand what exactly is going wrong. Help me please.

PS I just noticed that if the program ends normally, and not through manual interruption, then the browser window closes. It is closed by the same command, in the same finally block, I checked through debugging.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2022-03-05
@opium

Well, make a few committees back and see at what point

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question