SOAP UI- 自动化令牌检索过程不工作
SOAP UI- Automation token retrieval process not working
我已经在 Oauth 配置文件中的 SOAP UI 的自动化 window 中实现了 java 脚本。但这在用户手动运行之前不起作用。如何在我的令牌过期时自动调用脚本。
enter code here
function consent(){
document.getElementById('loginform').click();
}
if (document.getElementById('login')) {
document.getElementById('login').value = 'xxxx@xxx.com';
document.getElementById('password').value = 'xxxxx';
document.loginform.submit();
}
else if (document.getElementById('loginform')){
window.setInterval(content,100);
}
这是需要如何处理的。
- 调用服务获取令牌令牌。
- 上述响应还必须包含 headers 中的到期时间,将其提取并与令牌
一起存储在 属性 中
- 进行需要有效令牌的正常服务调用
- 在发送请求之前,找到当前时间并将其与步骤 2
中存储的 属性 进行比较
- 如果当前时间小于到期时间,使用相同的令牌
- 否则重复同样的步骤
现在,问题是如何 运行 在实际 运行 测试步骤之前随机编码?
您应该能够执行一些额外的代码,在这种情况下需要使用 setup
、teardown
脚本 test case, test suite, project
等,即
请允许我举例说明。
您正在 运行 测试用例,其中有一个调用某些服务的步骤,它需要 token
。
添加所需代码以评估是否要再次检索令牌或重新使用现有令牌。这应该是测试用例的设置脚本的一部分,因此设置脚本中的代码总是在 运行 测试用例之前执行。请记住,如果您在该测试用例的测试步骤中 运行,您的脚本将不会 运行,因此请确保您 运行 测试用例。
Note:
But, it can't be done for a test step level at the moment using SoapUI open source edition.
There is feature called Events
available in Ready! API
, where one can have very fine control on what to be done and when. This feature is not available in Open Source edition of SoapUI
.
But for open source, an extension available, which I did some time ago, where that will allow some one to run some custom code for certain events like beforeStep, afterStep etc., That is tried using Groovy Script. However, you seemed to be using Javascript here. If you wish you may give a try the extension, of course, if needed.
更新:
作为某些信息的问题请求的作者,因此更新答案。
您可以查看此文档 link,其中展示了如何使用专业软件的 custom events
功能在按需满足特定条件时执行更多操作。
SmartBear 团队也有一个 webinar 展示了如何使用事件,但时间不长。全部使用 groovy
.
我看到你在使用 Javascript
,有什么促使你使用它的吗?或者只是你觉得用起来舒服?没关系,你应该可以使用它。
我已经在 Oauth 配置文件中的 SOAP UI 的自动化 window 中实现了 java 脚本。但这在用户手动运行之前不起作用。如何在我的令牌过期时自动调用脚本。
enter code here
function consent(){
document.getElementById('loginform').click();
}
if (document.getElementById('login')) {
document.getElementById('login').value = 'xxxx@xxx.com';
document.getElementById('password').value = 'xxxxx';
document.loginform.submit();
}
else if (document.getElementById('loginform')){
window.setInterval(content,100);
}
这是需要如何处理的。
- 调用服务获取令牌令牌。
- 上述响应还必须包含 headers 中的到期时间,将其提取并与令牌 一起存储在 属性 中
- 进行需要有效令牌的正常服务调用
- 在发送请求之前,找到当前时间并将其与步骤 2 中存储的 属性 进行比较
- 如果当前时间小于到期时间,使用相同的令牌
- 否则重复同样的步骤
现在,问题是如何 运行 在实际 运行 测试步骤之前随机编码?
您应该能够执行一些额外的代码,在这种情况下需要使用 setup
、teardown
脚本 test case, test suite, project
等,即
请允许我举例说明。
您正在 运行 测试用例,其中有一个调用某些服务的步骤,它需要 token
。
添加所需代码以评估是否要再次检索令牌或重新使用现有令牌。这应该是测试用例的设置脚本的一部分,因此设置脚本中的代码总是在 运行 测试用例之前执行。请记住,如果您在该测试用例的测试步骤中 运行,您的脚本将不会 运行,因此请确保您 运行 测试用例。
Note:
But, it can't be done for a test step level at the moment using SoapUI open source edition.There is feature called
Events
available inReady! API
, where one can have very fine control on what to be done and when. This feature is not available in Open Source edition ofSoapUI
.But for open source, an extension available, which I did some time ago, where that will allow some one to run some custom code for certain events like beforeStep, afterStep etc., That is tried using Groovy Script. However, you seemed to be using Javascript here. If you wish you may give a try the extension, of course, if needed.
更新:
作为某些信息的问题请求的作者,因此更新答案。
您可以查看此文档 link,其中展示了如何使用专业软件的 custom events
功能在按需满足特定条件时执行更多操作。
SmartBear 团队也有一个 webinar 展示了如何使用事件,但时间不长。全部使用 groovy
.
我看到你在使用 Javascript
,有什么促使你使用它的吗?或者只是你觉得用起来舒服?没关系,你应该可以使用它。