简体   繁体   English

如何使用Java在Eclipse中运行WebDriver和JMeter代码

[英]How to run webdriver and JMeter code in Eclipse using Java

Below is my requirement : (1)I need to do UI performance testing . 以下是我的要求:(1)我需要进行UI性能测试。 (2)At the end of the test I want jmx file to be generated,I do have the batch file that will convert it to jtl and then to html report. (2)在测试结束时,我想生成jmx文件,我确实有将其转换为jtl然后转换为html报告的批处理文件。

Answers not known : (1)I did browse through a lot of links that explained how to execute webdriver code using JUnit in JMeter. 未知答案:(1)我确实浏览了许多链接,这些链接解释了如何在JMeter中使用JUnit执行Webdriver代码。 However I don't want to do that[run webdriver code in JMeter] and want my code to be a standalone code using HTMLUnit(headless browser) performing authentication and then the remaining click actions[Click on multiple links] ....Behind the scenes jmeter should record performance of every page and at end of test ,dump the results.Also it should be irrespective of testng /junit .Does anyone know if this is possible and can redirect me to the appropriate link.Thanks! 但是我不想这样做[希望在JMeter中运行webdriver代码],并希望我的代码成为使用HTMLUnit(无头浏览器)执行身份验证,然后执行其余点击操作[单击多个链接]的独立代码。场景jmeter应该记录每页的性能,并在测试结束时记录结果,转储结果。也应该与testng / junit无关。有人知道这是否可行,可以将我重定向到相应的链接。谢谢!

JMeter has nothing in common with the UI performance testing, as per JMeter main page : 根据JMeter主页JMeter与UI性能测试没有共同之处:

JMeter is not a browser , it works at protocol level. JMeter不是浏览器 ,它可以在协议级别运行。 As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); 就Web服务和远程服务而言,JMeter看起来像一个浏览器(或更确切地说,是多个浏览器)。 however JMeter does not perform all the actions supported by browsers. 但是,JMeter不会执行浏览器支持的所有操作。 In particular, JMeter does not execute the Javascript found in HTML pages. 特别是, JMeter不会执行HTML页面中的Javascript。 Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time). 它也不会像浏览器那样呈现HTML页面 (可以将响应查看为HTML等,但是计时不包含在任何示例中,并且一次仅在一个线程中显示一个示例)。

Both JUnit and TestNG automatically record function execution duration, you can build your test in such a way that measurable actions would be annotated with @Test annotation so the time will be automatically recorded. JUnitTestNG都会自动记录函数执行的持续时间,您可以通过以下方式构建测试:使用@Test注释对可测量的动作进行注释,以便自动记录时间。

In addition you can consider using Navigation Timing API from your WebDriver tests in order to get more information regarding page loading events. 另外,您可以考虑从WebDriver测试中使用Navigation Timing API ,以获取有关页面加载事件的更多信息。


If you still want to run JMeter tests from Java code - check out Five Ways To Launch a JMeter Test without Using the JMeter GUI article, it covers both running existing .jmx file and creating a new JMeter test purely using JMeter API from Java, however it is not applicable for your use case. 如果您仍然想从Java代码运行JMeter测试,请查看不使用JMeter GUI来启动JMeter测试的五种方法 ,该文章涵盖了运行现有.jmx文件和仅使用Java的JMeter API创建新的JMeter测试的方法。它不适用于您的用例。 The recommended way is to: 推荐的方法是:

  1. Create the main load using JMeter 使用JMeter创建主负载
  2. Measure client-side performance using Selenium 使用Selenium评估客户端性能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Java代码中运行JMeter JMX文件? - How to run a JMeter JMX file in Java code? 如何在Java代码中运行Jmeter脚本? - How to Run a Jmeter script within Java code? 在 Eclipse 中使用 Selenium WebDriver 和 java 代码在搜索字段中输入文本后如何按“Enter” - How to press 'Enter' once text is entered in the search field using Selenium WebDriver and java code in eclipse 如何使用 Java 或 Groovy 语言将 Jmeter Session 本地存储到 Jmeter Webdriver 示例中 - how to get Jmeter Session local storage into Jmeter Webdriver sample using Java or Groovy language 如何在 jmeter WebDriver 示例中注入 javascript 代码? - How to inject javascript code in jmeter WebDriver sample? 如何在Eclipse中将WebDriver与Java结合使用 - How to use WebDriver with Java in eclipse 如何在Eclipse Juno上运行Java代码 - How to run Java code on Eclipse Juno 如何通过Eclipse控制台运行Java代码? - How to run java code through eclipse console? 无法从Eclipse执行Webdriver Java代码 - Not able to execute a Webdriver Java Code from eclipse 使用带有java代码的jmeter-plugins-webdriver,出现ExpectedConditions的NoClassDefFoundError? - Useing jmeter-plugins-webdriver with java code , there is a NoClassDefFoundError of ExpectedConditions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM