简体   繁体   English

如何使用JavaScript语言在Jmeter WebDriver Sampler中设置InternetExplorerOptions?

[英]How to set InternetExplorerOptions in Jmeter WebDriver Sampler using JavaScript language?

I am new to Jmeter and selenium web driver. 我是Jmeter和Selenium Web驱动程序的新手。

I need some help to set the following options using JavaScript language in Webdriver Sampler. 我需要一些帮助来使用Webdriver Sampler中的JavaScript语言设置以下选项。

    InternetExplorerOptions options = new InternetExplorerOptions() options.IntroduceInstabilityByIgnoringProtectedModeSettings = true options.EnableNativeEvents = false 
    options.EnsureCleanSession = true

This is the template code that it has after adding Weddriver Sampler: 这是添加Weddriver Sampler之后的模板代码:

    WDS.sampleResult.sampleStart()
    WDS.browser.get('http://jmeter-plugins.org')
    WDS.sampleResult.sampleEnd()

Can someone please help me with the code sample on how to set it using JavaScript from loading the package and setting the options and incorporating into the template code above? 有人可以帮我提供有关如何使用JavaScript进行设置的示例代码,方法是加载程序包,设置选项以及将其合并到上面的模板代码中?

Thank you! 谢谢!

Please check the below snippet:- 请检查以下代码段:

var pkg = JavaImporter(org.openqa.selenium);

pkg.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
pkg.EnableNativeEvents = false; 
pkg.EnsureCleanSession = true;

WDS.sampleResult.sampleStart()
WDS.browser.get('http://jmeter-plugins.org')
WDS.sampleResult.sampleEnd()

Hope this helps. 希望这可以帮助。

As per WebDriver Sampler 3.1 it is not possible, the initialization is happening inside InternetExplorerDriverConfig.java class so you will either have to amend this class to include your changes, recompile the .jar and replace the one in JMeter Classpath 根据WebDriver Sampler 3.1,这是不可能的,初始化是在InternetExplorerDriverConfig.java类内部进行的,因此您将不得不修改此类以包括您的更改,重新编译.jar并替换JMeter Classpath中的那个。

or you can write your Selenium-related code using JSR223 Sampler in Groovy language , this way you will have full control over the WebDriver instance, but you will have to care about kicking off and shutting down the browser instance(s) 或者您可以使用Groovy语言的 JSR223 Sampler编写与Selenium相关的代码,这样您将完全控制WebDriver实例,但是您将不得不考虑启动和关闭浏览器实例。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM