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

AttributeError: 'WebDriver' object has no attribute 'requests' #48

Closed nu1ee closed 3 years ago

nu1ee commented 5 years ago

Unable to get header information after click?

from seleniumwire import webdriver

driver.get("http://url")
driver.find_element_by_xpath("//div[@id='toolbar']/div[2]/span").click()
for request in driver.requests:
 if request.response:
 print(request.response.headers['Referer'])

for request in driver.requests:
AttributeError: 'WebDriver' object has no attribute 'requests'
wkeeling commented 5 years ago

@nu1ee Can you share the code that creates the driver instance?

appunni-m commented 5 years ago

Make sure you are not importing both seleniumwire webdriver and selenium webdriver @nu1ee

On Tue, 14 May 2019 at 17:53, Will Keeling notifications@github.com wrote:

@nu1ee https://github.com/nu1ee Can you share the code that creates the driver instance?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wkeeling/selenium-wire/issues/48?email_source=notifications&email_token=AHQS45YNVKUF5JIDGACDPYLPVKVMPA5CNFSM4HMU6DK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVLJVDI#issuecomment-492214925, or mute the thread https://github.com/notifications/unsubscribe-auth/AHQS453H7RWNZTOWEGMIMQTPVKVMPANCNFSM4HMU6DKQ .

djstrong commented 4 years ago

Yes, the issue was importing from selenium import webdriver instead of seleniumwire.

from seleniumwire import webdriver

driver = webdriver.Firefox('./')
driver.get('https://google.com')

for r in driver.requests:
    print(r.path, r)