-
Hello, thanks for the awesome project! I'm trying to record all the requests browser make:
Then I perform some actions manually in the browser window that triggers the requests. Is there something I'm doing wrong? Thanks! P.S. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Assuming you haven't opened a new tab and switched to it, it should be picking up the requests. UC Mode may open a new tab when you navigate to a new URL in order to wipe clean any trace of selenium in the browser, which may cause the missing data. For those cases, you can use Example: from pprint import pformat
from seleniumbase import BaseCase
BaseCase.main(__name__, __file__, "--uc", "--uc-cdp", "-s")
class CDPTests(BaseCase):
def add_cdp_listener(self):
self.driver.add_cdp_listener("*", lambda data: print(pformat(data)))
def test_display_cdp_events(self):
self.get_new_driver(undetectable=True, uc_cdp_events=True)
self.driver.default_get("https://nowsecure.nl/#relax")
self.add_cdp_listener()
self.refresh()
self.sleep(1) Alternatively, you can use the from seleniumbase import Driver
driver = Driver(wire=True, headless=True)
try:
driver.get("https://wikipedia.org")
for request in driver.requests:
print(request.url)
finally:
driver.quit() |
Beta Was this translation helpful? Give feedback.
Assuming you haven't opened a new tab and switched to it, it should be picking up the requests. UC Mode may open a new tab when you navigate to a new URL in order to wipe clean any trace of selenium in the browser, which may cause the missing data. For those cases, you can use
driver.default_get(url)
, which will not use UC Mode for that URL, and the script will stay in the same tab. You can also dodriver.refresh()
from UC Mode.Example: