有什么办法可以从使用 Selenium 的 POST 请求开始吗? [英] Is there any way to start with a POST request using Selenium?

查看:39
本文介绍了有什么办法可以从使用 Selenium 的 POST 请求开始吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用对我的应用程序的 POST 请求来启动 Selenium 测试.

I'm trying to start a Selenium test with a POST request to my application.

代替简单的open(/startpoint)

我想做类似open(/startpoint, stuff=foo,stuff2=bar)

有没有办法做到这一点?

Is there any way to do that?

我之所以这么问是因为发布到此起点的原始页面取决于经常离线(开发环境)的外部提供商,因此通常会过早失败(并且不是测试的主题)

I'm asking this because the original page which posts to this start point depends on external providers that are often offline (development environment) and so will often fail too early (and are not the subject of the test)

我想以 GET 方式发送数据也可以.我更喜欢使用 POST 方法.

I guess sending data as GET would work too. I would just prefer using a POST method.

推荐答案

简短回答:否.

但是你也许可以用一点脏东西来做到这一点.如果您打开一个测试页面(使用 GET)然后在该页面上评估一些 JavaScript,您应该能够复制 POST 请求.请参阅像表单提交一样的 JavaScript 发布请求,了解如何在 JavaScript 中复制 POST 请求.

But you might be able to do it with a bit of filthing. If you open up a test page (with GET) then evaluate some JavaScript on that page you should be able to replicate a POST request. See JavaScript post request like a form submit to see how you can replicate a POST request in JavaScript.

希望这会有所帮助.

这篇关于有什么办法可以从使用 Selenium 的 POST 请求开始吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆