【问题标题】:How to calculate time for two different actions in JMeter Webdriver sampler如何计算 JMeter Webdriver 采样器中两个不同操作的时间
【发布时间】:2018-09-17 21:42:36
【问题描述】:

我想在 JMeter webdriver 采样器中记录两个不同操作的时间。 我面临的问题是,两者的记录时间相同。这是我的代码。

WDS.sampleResult.sampleStart()
WDS.log.info('Click on baseline icon and start time for device'+'${DeviceName}'+':-'  +WDS.sampleResult.getStartTime())
WDS.browser.findElement(pkg.By.xpath("//a[@id='baseline-icon-${DeviceName}']")).click()
WDS.sampleResult.sampleEnd()
WDS.log.info('Click on baseline icon and end time for device'+'${DeviceName}'+':-' + WDS.sampleResult.getEndTime())

WDS.sampleResult.sampleStart()

WDS.log.info('Baseline commit start time for device'+'${DeviceName}'+':-' +WDS.sampleResult.getStartTime())

wait.until(pkg.ExpectedConditions.elementToBeClickable(pkg.By.id( "commitToLib"))).click()
wait.until(pkg.ExpectedConditions.invisibilityOfElementLocated(pkg.By.xpath( "//*[@id='device-name-${DeviceName}']/../../../../../../..//div[contains(text(),'Manage Library is in progress')]")))
WDS.sampleResult.sampleEnd()

WDS.log.info('Baseline commit end time for device'+'${DeviceName}'+':-' + WDS.sampleResult.getEndTime())

getStartTime() 记录的时间在这两种情况下是相同的,而 getEndTime() 在两种情况下是相同的。

【问题讨论】:

    标签: jmeter webdriver


    【解决方案1】:

    您不能在WebDriver Sampler 的同一个实例中调用WDS.sampleResult.sampleEnd() 函数两次。

    我建议将您的操作分成 2 个 WebDriver 采样器,即

    • action 1 应该进入 WebDriver Sampler 1
    • action 2 进入WebDriver Sampler 2。

    WebDriver 实例在所有 WebDriver 采样器之间共享,因此您基本上可以从上次中断的地方继续,从 WebDriver 的角度来看,这没有区别。

    如果你想在报告中有action 1action 2的累积时间 - 将相关的WebDriver Samplers放在Transaction Controller

    【讨论】:

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