You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Long-term support concerns with network interception due to Selenium Wire deprecation #3246
We have several use cases that require request and response interception for UI testing, and we’re considering using SeleniumBase for this purpose. However, I noticed that SeleniumBase's wire mode relies on Selenium Wire, which is deprecated since January 2024.
Although network interception is still functional through Selenium Wire, I’m concerned about the impact on long-term support. Could you provide guidance on the following:
Are there plans to update or replace Selenium Wire within SeleniumBase to ensure continued support for network interception?
Is it advisable to continue using the current setup, or would you recommend alternative approaches for network interception within SeleniumBase?
Any insights on future plans for handling network intercepts would be greatly appreciated.
Usage is different from regular Selenium-Wire, but it can do all the same things (and more) with better flexibility/control.
The greatest benefit for some people is that CDP Mode is part of UC Mode, which provides stealth to avoid bot-detection.
The old Selenium-Wire integration is not compatible with UC Mode, but CDP Mode patches the previous issues with Selenium-Wire that prevented compatibility.
"""Using CDP.fetch.RequestPaused to filter content in real-time."""importmycdpfromseleniumbaseimportSBasyncdefrequest_paused_handler(event, tab):
r=event.requestis_image=".png"inr.urlor".jpg"inr.urlor".gif"inr.urlifnotis_image: # Let the data throughtab.feed_cdp(mycdp.fetch.continue_request(request_id=event.request_id))
else: # Block the data (images)TIMED_OUT=mycdp.network.ErrorReason.TIMED_OUTs=f"BLOCKING | {r.method} | {r.url}"print(f" >>> ------------\n{s}")
tab.feed_cdp(mycdp.fetch.fail_request(event.request_id, TIMED_OUT))
withSB(uc=True, test=True, locale_code="en") assb:
sb.activate_cdp_mode("about:blank")
sb.cdp.add_handler(mycdp.fetch.RequestPaused, request_paused_handler)
url="https://gettyimages.com/photos/firefly-2003-nathan"sb.cdp.open(url)
sb.sleep(5)
If people don't need the stealth features or the other improvements made to intercepting and handling network requests & responses, then they can continue using the existing Selenium-Wire integration as it currently stands. Or, if people want the upgrades, then the new integration is ready in CDP Mode, as shown above.
Reacted by kamonwatroj, Eduardo de Sousa Oliveira and Sujit Biswas
Activity
mdmintz commentedon Nov 6, 2024
The Selenium-Wire replacement is already included within SeleniumBase's new CDP Mode.
Here's an example of that, (SeleniumBase/examples/cdp_mode/raw_res_sb.py):
Usage is different from regular Selenium-Wire, but it can do all the same things (and more) with better flexibility/control.
The greatest benefit for some people is that CDP Mode is part of UC Mode, which provides stealth to avoid bot-detection.
The old Selenium-Wire integration is not compatible with UC Mode, but CDP Mode patches the previous issues with Selenium-Wire that prevented compatibility.
Here's another example, (SeleniumBase/examples/cdp_mode/raw_req_sb.py), where specific requests were filtered out (intercepted and blocked), to prevent images from loading:
If people don't need the stealth features or the other improvements made to intercepting and handling network requests & responses, then they can continue using the existing Selenium-Wire integration as it currently stands. Or, if people want the upgrades, then the new integration is ready in CDP Mode, as shown above.
mdmintz commentedon Nov 6, 2024
Closing this in favor of #3247.
unpacify commentedon Dec 23, 2024
okay so i tried this out with url = "https://www.kohls.com/product/prd-6908521/girls-5-16-zeroxposur-2-pc-cozy-active-knit-top-jogger-set.jsp?color=Plum&storeIds=348&prdPV=1"
and there's only 1 request response i need, and it doesnt return it. that's the "https://www.kohls.com/web/productInventoryPrice/6908521?storeNum=348" request, which usually returns a 403 error.
the depreciated selenium wire works and retrieves that request response, but is causing massive amounts of memory to be used.