zoukankan      html  css  js  c++  java
  • JMeter运行通过Chrome打开的website

    部分website在chrome上运行正常,但在IE环境运行会存在问题。而是用 JMeter运行通过chrome打开的website时候,需要处理一下。

    可以参考下面几篇文章:

    http://ninjawebzen.com/running-jmeter-with-chromedriver/

    摘录部分要点信息如下:

    Once download finished, extract zip archive somewhere temporary. Then open the folder where your JMeter located, navigate to ..apache-jmeter-2.13lib and paste all .jar files from WebDriver plugin ..lib. Open ..apache-jmeter-2.13libext and paste .jar file from WebDriver plugin ..libext.

    Right click on a Test Plan => Add => Threads => Config Element => and make verify is presented Chrome Driver Config.

    Now lets set the project:

    1. Add Thread Group
    2. Then Chrome Driver Config (right click on Thread Group => Add => Config Element => Chrome Driver Config)

    You would need to specify location of chromedriver.exe (btw download it, if you haven't yet), then open Chrome Driver Config and switch to Chrome tab and add path, it would be something like:

    C:Usersyour_usernameapache-jmeter-2.13libchromedriver.exe

    3. Add WebDriver Sampler (right click on Thread Group => Add => Sampler => WebDriver Sampler)
    And add some test code:

    var webdriver = JavaImporter(org.openqa.selenium)
    var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
    var conditions = org.openqa.selenium.support.ui.ExpectedConditions
    var wait=new support_ui.WebDriverWait(WDS.browser, 5)
    var exception = null
    
    WDS.sampleResult.sampleStart()
    WDS.browser.get('localhost:8080')
    
    var loginUrl = WDS.browser.findElement(webdriver.By.id('loginUrl_id'))
    loginUrl.click()
    
    var userName = WDS.browser.findElement(webdriver.By.id('username_id'))
    userName.sendKeys('admin')
    var password = WDS.browser.findElement(webdriver.By.id('password_id'))
    password.sendKeys('9')
    
    var loginBtn = WDS.browser.findElement(webdriver.By.id('loginBtn_id'))
    loginBtn.click()
    var wait=new support_ui.WebDriverWait(WDS.browser, 10)
    
    wait.until(conditions.presenceOfElementLocated(webdriver.By.linkText('Some Link Text')))

    Run the tests!

    You might have an error message like that on first run

    2015/08/04 13:41:37 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.impl.conn.ManagedHttpClientConnectionFactory

    Then problem is duplicate files in your lib folder, so if problem appear open JMeter lib folder and make sure there is no duplicates.

    like this:

    Here is original stackoverflow solution.

    For more information check out Blazemeter posts
    1. The WebDriver Sampler: Your Top 10 Questions Answered
    2. Using Selenium with JMeter's WebDriver Sampler

    另外,下面这两篇文章基本是源自前一篇文章,如果觉得有必要,也可以参考:

    https://guide.blazemeter.com/hc/en-us/articles/206732579-Chrome-Extension

    http://www.cnblogs.com/liulinghua90/p/5822148.html 

    就这样处理即可;

  • 相关阅读:
    execCommand快速实现复制到剪贴板
    webpack安装&指定版本安装&遇到的问题
    promise初体验
    使用原生JS发送AJAX请求(XML,JSON解析)
    【Python3】python中pymysql数据编码的问题
    闭包,闭包用途,call、apply、bind 的用法
    实现一个jQuery API
    Android 客户端和 web服务器通信
    Adb 基础
    在Android 中实现scp操作
  • 原文地址:https://www.cnblogs.com/haochuang/p/6932945.html
Copyright © 2011-2022 走看看