webfp / tor-browser-selenium

Tor Browser automation with Selenium.
MIT License
528 stars 101 forks source link

How to make tow window last after opening new one at the same time #167

Closed dveit closed 1 year ago

dveit commented 2 years ago

I am using tbselenium to open multiple unique browser windows to login to a site across multiple accounts.

from tbselenium.tbdriver import TorBrowserDriver

def main(username, password):
    with TorBrowserDriver("/path/tor-browser_en-US/") as browser:
        browser.switch_to.new_window('window')
        browser.get("https://example.com")
        # passing username and logging in

users = {'username1': 'password1', 'username2': 'password2'}

for key in users:
    main(key, users[key])

But as it completes with first one and starts second window, first one closes unexpectedly:

1638433529634   Marionette  INFO    Stopped listening on port 44711
[12-02 08:25:29] Torbutton INFO: Original window closed. Searching for another
[12-02 08:25:29] Torbutton INFO: Last window closed. None remain.

How do I get all windows to run at the same time and only close when the program exits? And how to disable debug information of the module being printed to the console?