Selenium Post method

31,835

You can try using selenium-requests:

Extends Selenium WebDriver classes to include the request function from the Requests library, while doing all the needed cookie and request headers handling.

Example:

from seleniumrequests import Firefox

webdriver = Firefox()
response = webdriver.request('POST', 'url here', data={"param1": "value1"})
print(response)
Share:
31,835
Walid Saad
Author by

Walid Saad

Updated on January 24, 2020

Comments

  • Walid Saad
    Walid Saad over 4 years

    I'm trying to find a way to get the response of a post method executed through headless browser.

    session = requests.Session()
    session.get(<url here)
    print session.cookies
    r = session.post(url).content
    print r
    

    The problem is that the response r is full of javascript and I can't use Selenium to execute it because it doesn't support the POST method (as far as I know). Any ideas?