Skip to content

Fetch Requests Data When Open a Page #2774

Closed
@adarmawan117

Description

@adarmawan117

I want to fetch all requests similar https://www.dilatoit.com/2020/12/17/how-to-capture-http-requests-using-selenium.html

from seleniumwire import webdriver  # Import from seleniumwire  

# Create a new instance of the Firefox driver  
driver = webdriver.Firefox()  

# Go to the Google home page  
driver.get('https://www.google.com')  

# Access and print requests via the `requests` attribute  
for request in driver.requests:  
	if request.response:  
		print(  
			request.url,  
			request.response.status_code,  
			request.response.headers['Content-Type'])  

How can i do with seleniumbase.?

I try to use

        for request in sb.driver.requests:
            if request.response:
                print(f"{request.url}\n{request.response.status_code}\n{request.response.headers['Content-Type']}")

But it give me error
AttributeError: 'Chrome' object has no attribute 'requests'

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionSomeone is looking for answers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions