Introduction
The following is selected from the "Xiao Qiang Software Testing Madness Handout" a book
Body
First had to sigh JMeter's increasingly powerful, especially its plug-ins. Before we explained, JMeter can complete the performance test, interface test, and this time it can rely on Webdriver to complete the GUI function Automation test.
Below we will open my blog address home page for an example to explain, the approximate implementation steps are as follows:
1) Download Jmeterplugins-webdriver-1.3.1.zip, unzip all the jar files in the Lib directory and lib/ The Jmeterplugins-webdriver.jar files in the Ext directory are copied to the Lib directory and the Lib/ext directory in the local JMeter installation directory, respectively.
2) go to the local JMeter installation directory of the Lib directory, the HttpClient, Httpcore, httpmime three jar package lower version of the deletion, only the higher version.
3) Start JMeter, you can see that the configuration component in Figure 3.38 has a few new driver Config.
650) this.width=650; "src=" Http://p1.pstatp.com/large/2ec60004be642d3ef7ca "alt=" use JMeter selenium in Webdriver to complete the test " style= "border-style:none;margin:10px auto;"/>
Figure 3.38 Configuring the component
4) New [email protected]-Firefox Driver config, as shown in configuration 3.39.
650) this.width=650; "src=" HTTP://P9.PSTATP.COM/LARGE/2EC10000F6561150B3CB "alt=" use JMeter selenium in Webdriver to complete the test " style= "border-style:none;margin:10px auto;"/>
Figure 3.39 [email protected]-Firefox Driver Config
5) New [email protected]-Webdriver Sampler, write the following code:
The test code begins and the business that needs to be tested is placed between start and end.
WDS.sampleResult.sampleStart ()
try{
Open Blog Home
WDS.browser.get (' http://xqtesting.blog.51cto.com ')
Test code End
WDS.sampleResult.sampleEnd ()
}catch (x) {
WDS.sampleResult.sampleEnd ()
Set to result failed
WDS.sampleResult.setSuccessful (False)
The return information is set to-_-sorry
WDS.sampleResult.setResponseMessage ('-_-sorry ')
}
6) Create a new view result tree and view the results in a table.
7) Run the JMeter script and you can see that Firefox is automatically invoked and simulated. As shown in the final run result 3.40.
650) this.width=650; "src=" http://p9.pstatp.com/large/2ecb00044f958a5c8e83 "alt=" use JMeter selenium in Webdriver to complete the test " style= "border-style:none;margin:10px auto;"/>
Figure 3.40 Running results
The above is the simplest use, is a taste of it, which Webdriver sampler code can be extended, and you write Webdriver, you can use the By.id,by.cssselector and other methods to locate and manipulate elements, similar to the following code:
var pkg = javaimporter (org.openqa.selenium)
WDS.browser.findElement (pkg. By.id (' What ')). SendKeys ([' Xiaoqiang ')]
Interested friends can visit the official website for detailed sample code, address:
http://jmeter-plugins.org/wiki/WebDriverSampler/.
This article is from the "Cockroach Performance automation test brand" blog, please be sure to keep this source http://xqtesting.blog.51cto.com/4626073/1947396
Complete the test using selenium webdriver in JMeter