0

I'm using Chrome browser, how I can send a post request with selenium?

I found this answer Is there any way to start with a POST request using Selenium?, but the suggested solution is a little bit outdated (last update in 2016) The outdated library https://pypi.org/project/selenium-requests/

My code:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

driver = webdriver.Chrome(executable_path=driver_path, options=options)
response = driver.request('POST', url, data={"key_1": 'value_1', 'key_2': 'value_2'})
#  AttributeError: 'WebDriver' object has no attribute 'request'

P.S. I was surprised when not found already existing answer.

salius
  • 105
  • 6

1 Answers1

0

I believe Selenium concentrates on browser automation, and since you can't directly POST in Chrome, Selenium doesn't provide that either.

Generally I think you need to use a more general HTTP API, rather than Selenium, to POST and grab the response.

I guess you could also create a web page that POSTs, and use Selenium to operate that web page.

Conrad Albrecht
  • 1,658
  • 1
  • 13
  • 17