selenium-wire icon indicating copy to clipboard operation
selenium-wire copied to clipboard

Clear driver.requests list after visiting a webpage

Open extratrees opened this issue 2 years ago • 2 comments

Hello, First of all kudos for this great library. This is not a true issue rather than a question. I was wondering if there was the possibility of clearing the requests attribute of the webdriver before visiting a new page, as I would like to avoid stopping and restarting a new driver for each web page.

extratrees avatar Sep 02 '22 16:09 extratrees

Have you tried del driver.requests? E.g

driver.get(...)  # visit a page 

del driver.requests  # clear requests 

driver.get(...)  # visit a new page

wkeeling avatar Sep 03 '22 14:09 wkeeling

Thanks @wkeeling, that was not my issue but I needed that information as well. That is working very well and. 🙏🏼

Ps. Thanks for great library. 💯

halil-erdogan avatar Sep 20 '22 11:09 halil-erdogan

Hi, I would request / recommend adding a way for this del driver.requests call to be atomic, e.g. in this example:

driver.get(...)  # visit a page 
del driver.requests  # clear requests 
driver.get(...)  # visit a new page

It seems to be possible that driver.requests still gets populated by the first page after the del driver.requests call.

Ideally, we could be guaranteed that the second driver.get call would start with an empty driver.requests, so we could know exactly which requests were associated with that page.

maxp-hover avatar Jun 28 '23 17:06 maxp-hover