wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.9k stars 254 forks source link

keep running after a crash(No internet problem) #508

Closed hossein-m18 closed 2 years ago

hossein-m18 commented 2 years ago

in selenium lib after a crash in code or after ending the code i can keep using the browser and it still working but in seleniumwire after a crash browser disconected and show No internet error how can i set it in seleniumwire to keep connected after a code crash or ending code for manually using browser?

wkeeling commented 2 years ago

Thanks for raising this.

Selenium Wire works by configuring the browser to send requests to a hidden proxy server that Selenium Wire starts in the background. This proxy server allows the requests to be intercepted and captured. When your code crashes, the proxy server will stop running meaning that the browser won't be able to contact it and the requests it sends will fail.

One solution is to wrap your code in a try/except to ensure that Selenium Wire continues to run in the event of a crash. If the code completes normally (does not crash) and you still want to keep the browser alive, you can add a time.sleep() or input() at the end of your code to ensure it remains running.