简体   繁体   English

Jmeter WebDriver Sampler如何加载Firefox Profile

[英]Jmeter WebDriver Sampler How to load Firefox Profile

I am writing the JMeter script for sampling the UI response time for each event using WebDriver Sampler plugin. 我正在编写JMeter脚本,用于使用WebDriver Sampler插件对每个事件的UI响应时间进行采样。

My application allows only certificate-auth access to the GUI. 我的应用程序只允许对GUI进行证书身份验证访问。 So my question is like can we load a custom profile for Firefox using WebDriverSampler or how can we handle the client-auth using WebDriver sampler 所以我的问题是我们可以使用WebDriverSampler为Firefox加载自定义配置文件,或者我们如何使用WebDriver采样器处理客户端身份验证

be it any browser (firefox/chrome/IE) etc.... 无论是任何浏览器(firefox / chrome / IE)等....

I tried to update system.properties file under Jmeter3.0/bin/system.properties with below values. 我尝试使用以下值更新Jmeter3.0/bin/system.properties下的system.properties文件。

#webdriver.firefox.profile=profileName

#jmeter -Dwebdriver.firefox.profile=profileName

but the profile doesn't load up and I get the error: 但配置文件没有加载,我收到错误:

SECURE CONNECTION FAILED 安全连接失败

Do we have the WebDriver-Sampler-Server.jar for JMeter ?? 我们有JMeter的WebDriver-Sampler-Server.jar吗?

Or can we handle the same using JavaScript?? 或者我们可以使用JavaScript处理相同的问题吗?

You may pass your firefox profile name as parameter to FireFoxDriver constructor like below and then create a jar file out of it and refer in Jmeter. 您可以将firefox配置文件名称作为参数传递给FireFoxDriver构造函数,如下所示,然后创建一个jar文件并在Jmeter中引用。

ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("profileName");  //Pass your profilename
WebDriver driver = new FirefoxDriver(myprofile);

Hope this helps 希望这可以帮助

Looking into: 展望:

it seems it is not possible using current version of WebDriver Sampler plugin with any browser. 似乎不可能在任何浏览器中使用当前版本的WebDriver Sampler插件。

So the options are: 所以选项是:

  1. You can patch FirefoxDriverConfig file yourself to add the possibility to load ie Firefox Profile instead of creating it on the fly. 您可以自己修补FirefoxDriverConfig文件,以添加加载即Firefox配置文件的可能性,而不是动态创建它。
  2. You can switch to JUnit Request sampler which allows executing arbitrary JUnit tests right from JMeter. 您可以切换到JUnit Request sampler,它允许直接从JMeter执行任意JUnit测试。 See How to Use JUnit With JMeter article for details on using JMeter and JUnit integration. 有关使用JMeter和JUnit集成的详细信息,请参见如何将JUnit与JMeter一起使用。
  3. You can write your Selenium code directly in JSR223 Sampler 您可以直接在JSR223 Sampler中编写Selenium代码

NB: options 2 and 3 will require Selenium and dependency libraries presence in JMeter's classpath 注意:选项2和3将需要Selenium和依赖库存在于JMeter的类路径中

To run Selenium with custom profile we need to perform following steps - 要使用自定义配置文件运行Selenium,我们需要执行以下步骤 -

First, we need to instantiate the inbuilt class in selenium "ProfilesIni". 首先,我们需要在selenium“ProfilesIni”中实例化内置类。 Load your custom profile with the help of getProfile() method. 在getProfile()方法的帮助下加载您的自定义配置文件。 We actually are creating the clone of the custom profile. 我们实际上正在创建自定义配置文件的克隆。 Now assign this custom profile to your webdriver instance. 现在将此自定义配置文件分配给您的webdriver实例。

// Instantiating the ProfilesIni ProfilesIni firefoxprofile = new ProfilesIni(); //实例化ProfilesIni ProfilesIni firefoxprofile = new ProfilesIni();

    // Loading the custom profile;

    FirefoxProfile myProfile = firefoxprofile.getProfile("SeleniumBix");

    // Creating web driver instance
    WebDriver driver = new FirefoxDriver(myProfile);

    //Opening the SeleniumBix in New profile
    driver.get("http://www.seleniumbix.com");

For more Datils you can refer this amazing tutorial - http://www.seleniumbix.com/#!firefox-profile-with-selenium-webdriver/cdci 有关更多Datils,您可以参考这个惊人的教程 - http://www.seleniumbix.com/#!firefox-profile-with-selenium-webdriver/cdci

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

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