[英]How to Encrypt data in JMeter script
I am writing a simple script in Jmeter to pass username and password to the logging page of a website. 我正在Jmeter中编写一个简单的脚本,以将用户名和密码传递到网站的日志记录页面。 I want password to be encrypted but I am not sure if Selenium Webdriver API provide any functions to encerypt data before passing it into the sendKeys() function.
我希望对密码进行加密,但是不确定Selenium Webdriver API是否在将数据传递到sendKeys()函数之前是否提供了用于加密数据的功能。
Here's what my script looks like: 这是我的脚本的样子:
WDS.sampleResult.sampleStart()
WDS.browser.get('url')
var pkg = JavaImporter(org.openqa.selenium, org.openqa.selenium.support.ui)
var wait = new pkg.WebDriverWait(WDS.browser, 5000)
var user = WDS.browser.findElement(pkg.By.id('userName'))
user.sendKeys(['username])
var pass = WDS.browser.findElement(pkg.By.id('password'))
pass.sendKeys(['password'])
PS: I know the approach to pass data from CSV but that's not exactly encryption. PS:我知道从CSV传递数据的方法,但这并不是完全加密。
Put the jar that contains the encryption algorithm in jmeter/lib. 将包含加密算法的jar放在jmeter / lib中。
Suppose this class is in class com.foo.utils.encryption.EncryptionUtils, you would do: 假设此类位于com.foo.utils.encryption.EncryptionUtils类中,则可以执行以下操作:
var pkg = JavaImporter(com.foo.utils.encryption)
var encryptUtils = new pkg.EncryptionUtils()
vars.put("result", encryptUtils.method(inputString));
You can then use the ${result} variable. 然后,您可以使用$ {result}变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.