- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我已经使用 angular2.0
和 typescript
构建了一个网络应用程序。现在我正在使用 protractor
为我的站点编写 E2E
。
现在,在我的一个测试中,我需要进行 API 调用(HTTP GET 请求)并将响应值用作我的测试用例中的输入。
所以基本上我想知道如何在 Protractor-Jasmine
中发出 GET 请求
并使用结果/响应。
最佳答案
Protractor 在 nodejs 之上运行,并在底层调用 Selenium API。您可以使用所有节点库,包括 request
。
在导入/要求之间选择:
import * as request from 'request';
var request = require('request');
并执行您的GET
请求:
it('Should reach google.com', done => {
request('http://www.google.com', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
done(); //informs runner that the asynchronous code has finished
});
});
查看此链接:
关于angular - 在运行 Protractor 测试时进行 API 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45182309/
我正在尝试获取有关某个特定人员的最新信息,并且我正在使用类似的查询 SELECT * FROM Table WHERE Name LIKE 'Peter' ORDER BY ID DESC LIMIT
我有一个视频 View ,正在播放视频。我想停止视频并在触摸视频 View 时返回。我想我必须这样做。 videoView.setOnTouchListener(new OnTo
假设您正在为某种目的(例如数据结构)制作一个经过严格测试的相当健壮的 API。其他人将在他们自己的编码项目中下载和使用您的库,因此您希望它非常密封。 在您的 API 中,您有许多这样的函数调用: vo
想知道是否有办法可以在没有构造函数的情况下渲染组件。 下面是我的 onClick 代码。我的目标是当您单击按钮时进行渲染以使按钮消失。我不确定是否有办法在不创建的情况下渲染它 constructor
我目前正在这样做。 有更好的方法吗? public Cursor selectRostersForTeam(Activity activity, int teamId) { final Str
我们遇到了遗留代码的问题。有一个“用户名”字段的验证集,验证它的长度并确保它至少包含一个字母: @Column(name = "username") @Size(min = 4, max = 40)
所以我有一个通过 .fetch() 填充的模型,我的问题是。它要么总是 PUT,要么总是 POST,但 .save() 永远不会表现得“智能”。 该模型是通过提取填充的,如果从提取返回任何内容,它最多
到目前为止,我已经能够为 Azure Functions 设置单元测试并且效果很好。但是对于我当前的项目,我需要使用动态或命令式绑定(bind)。 https://learn.microsoft.co
我有一个很大的本地文件。我想使用 boto 库将该文件的 gzip 版本上传到 S3。该文件太大,无法在上传前将其有效地 gzip 到磁盘上,因此应在上传期间以流式方式 gzip。 boto 库知道一
我正在使用 python 的 slumber 库对服务进行 HTTP 调用。这就是它的样子。我需要对此 URL https://sample-billing-api.test/2/billing-ac
使用 manifest v2 可以正常工作。但是使用 manifest v3 我收到错误“ReferenceError: localStorage is not defined” manifest.j
我是一名优秀的程序员,十分优秀!