【问题标题】:JMeter jp@gc-WebDriver Sampler — Run the Webpage from CSV FileJMeter jp@gc-WebDriver Sampler — 从 CSV 文件运行网页
【发布时间】:2021-02-16 09:06:14
【问题描述】:

我尝试使用 CSV 数据集配置从 CSV 文件创建登录。但不知道为什么它没有选择变量并且在登录页面上输入了带有“用户名”和“密码”的措辞。可以请教吗?

import org.openqa.selenium.*; import org.openqa.selenium.support.ui.*; import org.openqa.selenium.support.ui.Select; WDS.sampleResult.sampleStart(); WDS.browser.get("https://uat-testing.com/" ); sleep(5000); var Username = WDS.vars.get("username" ); var Password = WDS.vars.get("password" ); WDS.log.info('Username' + Username ); WDS.log.info('Password' + Password ); WDS.browser.findElement(org.openqa.selenium.By.xpath("//input[@type='text']" )).sendKeys("Username" ); WDS.browser.findElement(org.openqa.selenium.By.xpath("//input[@type='password']" )).clear(); WDS.browser.findElement(org.openqa.selenium.By.xpath("//input[@type='password']" )).sendKeys("Password" ); WDS.browser.findElement(org.openqa.selenium.By.xpath("//button/span" )).click(); sleep(10000); WDS.sampleResult.sampleEnd();

【问题讨论】:

    标签: groovy jmeter jmeter-plugins


    【解决方案1】:

    您需要从这些行中删除引号:

    sendKeys("Username" )
    

    sendKeys("Password" ); 
    

    所以它们看起来像:

    sendKeys(Username)
    

    sendKeys("Password" ); 
    

    同样使用sleep function is a performance anti-pattern,我更推荐使用Explicit Wait,这样您的测试将在满足条件后立即进行,而不是强制流休眠10秒,请参阅5 Ways to Test AJAX Calls in Selenium WebDriver了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多