Json 如何创建动态用户凭据,然后在soapui pro中的后续REST请求中使用它们?
一般来说,我对后端测试和所有脚本编写都很陌生,但使用selenium IDE在前端测试中很容易做到这一点。基本上,在我的自动化中,我希望在每次运行自动化时创建一个新的动态用户名/电子邮件和密码,并在套件的所有进一步测试中使用这些凭据 我创建了一个凭据测试步骤,其中用户名和密码设置如下: 用户名:testemail{Math.round(Math.random()*100000)}@example.com 密码:woof{Math.round(Math.random()*100000)} 在注册API REST请求中,我输入了以下json { } 但它似乎是这样来的: { }Json 如何创建动态用户凭据,然后在soapui pro中的后续REST请求中使用它们?,json,api,rest,soapui,Json,Api,Rest,Soapui,一般来说,我对后端测试和所有脚本编写都很陌生,但使用selenium IDE在前端测试中很容易做到这一点。基本上,在我的自动化中,我希望在每次运行自动化时创建一个新的动态用户名/电子邮件和密码,并在套件的所有进一步测试中使用这些凭据 我创建了一个凭据测试步骤,其中用户名和密码设置如下: 用户名:testemail{Math.round(Math.random()*100000)}@example.com 密码:woof{Math.round(Math.random()*100000)} 在注册A
我做错了什么?感谢您的帮助 随机值的生成和设置属性应该在groovy脚本测试步骤中完成。在groovy脚本中,按如下方式编写smth:
import java.util.Random
//generating random values
Random rand = new Random()
String username = "testmail" + rand.nextInt(100000) + "@example.com"
String password = "woof" + rand.nextInt(100000)
//setting test case properties
testRunner.testCase.setPropertyValue("username", username);
testRunner.testCase.setPropertyValue("password", password);
在测试用例中,您可以作为${#testcase_name#property_name}访问此属性
有关此处属性的更多信息:关于这里的脚本:
"email": "testemail{Math.round (Math.random() * 100000)}@example.com" ,
"password": "woof{Math.round (Math.random() * 100000)}" ,
"country": "us" ,
"firstname": "John" ,
"lastname": "Smith" ,
"lang": "C"
import java.util.Random
//generating random values
Random rand = new Random()
String username = "testmail" + rand.nextInt(100000) + "@example.com"
String password = "woof" + rand.nextInt(100000)
//setting test case properties
testRunner.testCase.setPropertyValue("username", username);
testRunner.testCase.setPropertyValue("password", password);