JMeter運行通過Chrome開啟的website

來源:互聯網
上載者:User

標籤:sample   localhost   部分   ssd   sage   error:   zip   this   find   

部分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.13\lib and paste all .jar files from WebDriver plugin ..\lib. Open ..\apache-jmeter-2.13\lib\ext and paste .jar file from WebDriver plugin ..\lib\ext.

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:\Users\your_username\apache-jmeter-2.13\lib\chromedriver.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.ExpectedConditionsvar wait=new support_ui.WebDriverWait(WDS.browser, 5)var exception = nullWDS.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 

 

就這樣處理即可;

JMeter運行通過Chrome開啟的website

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.