SOAP UI-自动化令牌检索过程不起作用 [英] SOAP UI- Automation token retrieval process not working

查看:67
本文介绍了SOAP UI-自动化令牌检索过程不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 Oauth 配置文件的 SOAP UI 的自动化窗口中实现了 java 脚本.但这在用户手动运行之前不起作用.如何在我的令牌过期时自动调用脚本.

I have implemented the java script in the Automation window of SOAP UI in the Oauth Profile. But this is not working until user runs it manually. How to automatically call the script whenever my token will expired.

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);
}

推荐答案

这是需要如何处理的.

  1. 调用服务以获取令牌.
  2. 上述响应还必须在标头中包含到期时间,提取它并与令牌一起存储在一个属性中
  3. 进行需要有效令牌的正常服务调用
    • 在发送请求之前,找到当前时间并将其与步骤 2 中存储的属性进行比较
    • 如果当前时间小于到期时间,则使用相同的令牌
    • 否则重复相同的步骤

现在,问题是如何在实际运行测试步骤之前运行随机代码?

Now, the question stand is how to run random code before actually running a test step?

你应该能够执行一些额外的代码,这是在这种情况下需要的,使用测试用例、测试套件、项目的setupteardown脚本 等,即,

You should be able to execute some extra code, which is need in this case, using setup, teardown scripts of test case, test suite, project etc. i.e.,

让我用一个例子来解释.

您正在运行一个测试用例,其中包含调用某些服务的步骤,并且需要 token.

You are running a test case which has a step to invoke some service and it requires token.

添加所需代码以评估是否要再次检索令牌或重用现有令牌.这应该是测试用例的设置脚本的一部分,以便在运行测试用例之前总是执行设置脚本中的代码.请记住,如果您在该测试用例的测试步骤上运行,您的脚本将不会运行,因此请确保您运行该测试用例.

Add the required code to evaluate whether a token is to be retrieved again or reuse the existing one. This should be part of setup script of the test case, so that always the code in setup script gets executed before running a test case. Remember that, your script will not be run if you run on test step of that test case, so make sure you run the test case.

注意:
但是,目前无法使用 SoapUI 开源版本完成测试步骤级别.

Note:
But, it can't be done for a test step level at the moment using SoapUI open source edition.

Ready! 中有一个名为 Events 的功能可用!API,可以很好地控制要做什么和何时做.此功能在 SoapUI 的开源版本中不可用.

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.

但是对于开源,有一个扩展可用,我前段时间做了,那将允许某人为某些事件(如 beforeStep、afterStep 等)运行一些自定义代码,这是使用 Groovy 脚本尝试过的.但是,您似乎在这里使用了 Javascript.如果您愿意,当然,如果需要,您可以尝试扩展.

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.

更新:

作为问题的作者要求提供一些信息,所以更新答案.

As author of question request for some info, so updating the answer.

你可以看看这个文档link 展示了如何使用专业软件的 custom events 功能在按需满足某些条件时执行更多操作.

You can have a look this documentation link which shows how to use the custom events functionality of pro software to do something more when certain conditions are met on demand.

还有一个由 SmartBear 团队举办的网络研讨会,展示了如何使用事件,但时间不长.全部使用groovy.

Also there is a webinar by SmartBear team which shows how to use events, but little lengthy in time. All uses groovy.

我看到您在使用 Javascript,有什么促使您使用它的吗?还是只是你用起来舒服?没关系,你应该可以使用它.

I see you using Javascript, is there anything that driving you to use it? or just you comfortable using it? Never mind, you should be able to use it.

这篇关于SOAP UI-自动化令牌检索过程不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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