简体   繁体   中英

httplib_response = conn.getresponse(buffering=True) TypeError: getresponse() got an unexpected keyword argument 'buffering' using Selenium?

I try to find an element on Amazon

def find_amazon_element():
    driver = webdriver.Firefox(executable_path=os.path.join('geckodriver'))
    driver.maximize_window()
    time.sleep(5)
    driver.get(url='https://www.amazon.com')
    input_field = driver.find_element_by_xpath('//*[@id="twotabsearchtextbox"]')
    search_button = driver.find_element_by_xpath('/html/body/div[1]/header/div/div[1]/div[3]/div/form/div[2]/div/input')
    input_field.send_keys('vase')
    search_button.click()
    time.sleep(5)
    driver.quit()

if __name__ == "__main__":
    find_amazon_element()

but I get this error

httplib_response = conn.getresponse(buffering=True) TypeError: getresponse() got an unexpected keyword argument 'buffering'

This error message...

httplib_response = conn.getresponse(buffering=True) TypeError: getresponse() got an unexpected keyword argument 'buffering'

...implies that the getresponse() method got an unexpected keyword argument buffering .

As per the discussion unexpected keyword argument 'buffering' - python client this exception isn't the source of the exception that stopped your test execution but it was in fact being handled when a different exception occurred.

Perhaps the complete Traceback would have helped us to debug the issue in a better way.

However, I am sure, if you go down through the Traceback you will find a line as, ...During handling of the above exception, another exception occurred:... with an error:

Caused by <class 'ConnectionResetError'>:
    [WinError 10054] An existing connection was forcibly closed by the remote host)

As per the discussion urllib3.exceptions.ProtocolError: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host')) this error is raised due to the incompatibility between the version of the binaries you are using.

Solution

Ensure that the version of the binaries you are using are compatible as per the figure below:

supported_platforms_geckodriver

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM