python - webdriver - post request

2,088 views
Skip to first unread message

bruce

unread,
Nov 21, 2016, 8:51:05 PM11/21/16
to seleniu...@googlegroups.com
Hi.

Can anyone point to code/sites/etc on how to implement a POST request
in selenium.

I'd prefer something with a basic example, but I'll deal with what I can.

Selenium with GET is trivial, but can't see how to do the POST.

Thanks

Andreas Tolfsen

unread,
Nov 21, 2016, 9:05:05 PM11/21/16
to seleniu...@googlegroups.com
bruce <bado...@gmail.com> writes:

> Can anyone point to code/sites/etc on how to implement a POST request
> in selenium.

WebDriver doesn’t interact at the HTTP request level. To do that you
might be interested in libcurl or similar.

bruce

unread,
Nov 22, 2016, 7:30:30 AM11/22/16
to seleniu...@googlegroups.com
wth!!

driver = webdriver.Firefox()
driver.wait = WebDriverWait(driver, 5)


url='http://austin.bncollege.com'

out=driver.get(url) <<<<< this performs the http 'GET'

where/how does one do a similar "POST"

not sure what the person who answered is discussing...





>
> --
> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
> To post to this group, send email to seleniu...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1479780261.20526.23.camel%40mozilla.com.
> For more options, visit https://groups.google.com/d/optout.

Jim Evans

unread,
Nov 22, 2016, 9:15:30 AM11/22/16
to Selenium Users
The method is named the same as the HTTP verb, but as Andreas (ato) said, it's not a perfect correlation. WebDriver doesn't perform the HTTP request directly; it instructs the browser to do so. There is no corresponding `post()` method in the WebDriver API. You'll need to instruct the browser to perform the POST operation however you would normally do that as a user. Typically, this is done by clicking on some element on a page, or submitting a form. If you need finer grained control than that, and are expecting to directly manipulate the HTTP request being sent to the server, WebDriver isn't the right library for that.
Reply all
Reply to author
Forward
0 new messages