Skip to content

Commit

Permalink
Version 2.0, for POST multipart/form-data don't put the content of th…
Browse files Browse the repository at this point in the history
…e file in the Record.xml file because binary content could be large and not XML compatible, add parameters : page_start_number and sampler_start_number to facilitate partial recording of website navigation.
  • Loading branch information
DABURON Vincent committed Mar 12, 2024
1 parent 53c87f8 commit f255778
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ Parameters are :
e.g. record_out = record.xml
* new_tc_pause time between 2 urls to create a new page (Transaction Controller) (default 5000 = jmeter property value : proxy.pause=5000) <br/>
* e.g. 5000 for 5 sec between 2 urls
* page_start_number, set the start page number for partial recording (default 1, must be an integer > 0) <br/>
* sampler_start_number, set the start sampler number for partial recording (default 1, must be an integer > 0) <br/>
* filter_include, the regular expression matches the URL to Include <br/>
* default all = empty (no filter)
* e.g. filter_include = https://mysite.com/.*
* e.g. filter_include=https://mysite.com/.*
* filter_exclude, the regular expression matches the URL to Exclude <br/>
* default all = empty (no filter)
* e.g. filter_include = https://notmysite.com/.*
* e.g. filter_exclude=https://notmysite.com/.*
* or filter statics, filter_exclude=(?i).*\.(bmp|css|js|gif|ico|jpe?g|png|swf|eot|otf|ttf|mp4|woff|woff2)
* add_pause checkbox, add Flow Control Action Pause, parameter new_tc_pause must be > 0 (default true) <br/>
* remove_cookie checkbox , remove header with cookie because add a Cookie Manager in the script (default true) <br/>
* remove_cache_request checkbox, remove cache request header because add a Cache Manager in the script (default true) <br/>


Status, the status line contains the tool status or the tool result.

e.g. : Status Results **OK**
Expand Down Expand Up @@ -82,7 +86,8 @@ Help to see all parameters :
C:\apache-jmeter\bin&gt;har-convertor-to-jmeter.cmd -help
usage: io.github.vdaburon.jmeter.har.HarForJMeter [-add_pause &lt;add_pause&gt;] [-filter_exclude &lt;filter_exclude&gt;]
[-filter_include &lt;filter_include&gt;] -har_in &lt;har_in&gt; [-help] -jmx_out &lt;jmx_out&gt; [-new_tc_pause &lt;new_tc_pause&gt;]
[-record_out &lt;record_out&gt;] [-remove_cache_request &lt;remove_cache_request&gt;] [-remove_cookie &lt;remove_cookie&gt;]
[-page_start_number &lt;page_start_number&gt;] [-record_out &lt;record_out&gt;] [-remove_cache_request
&lt;remove_cache_request&gt;] [-remove_cookie &lt;remove_cookie&gt;] [-sampler_start_number &lt;sampler_start_number&gt;]
io.github.vdaburon.jmeter.har.HarForJMeter
-add_pause &lt;add_pause&gt; Optional boolean, add Flow Control Action Pause after Transaction
Controller (default true)
Expand All @@ -95,13 +100,16 @@ io.github.vdaburon.jmeter.har.HarForJMeter
jmeter property : proxy.pause, need to be &gt; 0 if set. Usefully for Har
created by Firefox or Single Page Application (Angular, ReactJS, VuesJS
...)
-page_start_number &lt;page_start_number&gt; Optional, the start page number for partial recording (default 1)
-record_out &lt;record_out&gt; Optional, file xml contains exchanges likes recorded by JMeter
-remove_cache_request &lt;remove_cache_request&gt; Optional boolean, remove cache header in the http request (default true
because add a Cache Manager)
-remove_cookie &lt;remove_cookie&gt; Optional boolean, remove cookie in http header (default true because add
a Cookie Manager)
-sampler_start_number &lt;sampler_start_number&gt; Optional, the start sampler number for partial recording (default 1)
E.g : java -jar har-for-jmeter-&lt;version&gt;-jar-with-dependencies.jar -har_in myhar.har -jmx_out scriptout.jmx
-new_tc_pause 5000 -add_pause true -filter_include "https://mysite/.*" -filter_exclude "https://notmysite/*"
-page_start_number 50 -sampler_start_number 250
</pre>


Expand All @@ -123,8 +131,10 @@ The maven groupId, artifactId and version, this plugin is in the **Maven Central
```xml
<groupId>io.github.vdaburon</groupId>
<artifactId>har-convertor-jmeter-plugin</artifactId>
<version>1.0</version>
<version>2.0</version>
```
## Versions
Version 1.0 date 2024-0311, First Release
Version 2.0 date 2024-03-12, for POST multipart/form-data don't put the content of the file in the Record.xml file because binary content could be large and not XML compatible. Add parameters : page_start_number and sampler_start_number to facilitate partial recording of website navigation.

Version 1.0 date 2024-03-11, First Release.

Binary file modified doc/images/har_convertor_tool_gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.vdaburon</groupId>
<artifactId>har-convertor-jmeter-plugin</artifactId>
<version>1.0</version>
<version>2.0</version>
<packaging>jar</packaging>

<name>Apache JMeter Plugin to convert a HAR file to a JMeter script and Record XML</name>
Expand Down Expand Up @@ -74,7 +74,7 @@
<dependency>
<groupId>io.github.vdaburon</groupId>
<artifactId>har-to-jmeter-convertor</artifactId>
<version>1.0</version>
<version>2.0</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class HarConvertorGui extends AbstractAction implements
private JTextField fileJmxOutTextField;
private JTextField fileRecordOutTextField;
private JTextField pauseBetweenUrlTextField;
private JTextField pageStartNumberTextField;
private JTextField samplerStartNumberTextField;
private JButton fileHarInFileButton;
private JTextField regexFilterIncludeField;
private JTextField regexFilterExcludeField;
Expand Down Expand Up @@ -183,6 +185,34 @@ public void actionPerformed(ActionEvent action) {
}
}

String sPageStartNumber = pageStartNumberTextField.getText();
int pageStartNumber = 1;
if (!sPageStartNumber.isEmpty()) {
try {
pageStartNumber = Integer.parseInt(sPageStartNumber);
} catch (Exception ex) {
log.warn("Error parsing int parameter " + ", value = " + sPageStartNumber + ", set to 1");
pageStartNumber = 1;
}
}
if (pageStartNumber <= 0) {
pageStartNumber = 1;
}

String sSamplerStartNumber = samplerStartNumberTextField.getText();
int samplerStartNumber = 1;
if (!sSamplerStartNumber.isEmpty()) {
try {
samplerStartNumber = Integer.parseInt(sSamplerStartNumber);
} catch (Exception ex) {
log.warn("Error parsing int parameter " + ", value = " + sSamplerStartNumber + ", set to 1");
samplerStartNumber = 1;
}
}
if (samplerStartNumber <= 0) {
samplerStartNumber = 1;
}

boolean isRemoveCookieHeader = isRemoveCookieCheckbox.isSelected();
boolean isRemoveCacheRequestHeader = isRemoveCacheRequestHeaderCheckbox.isSelected();

Expand All @@ -199,10 +229,11 @@ public void actionPerformed(ActionEvent action) {
log.info("regexFilterInclude=<" + regexFilterInclude + ">");
log.info("regexFilterExclude=<" + regexFilterExclude + ">");
log.info("isRemoveCookieHeader=<" + isRemoveCookieHeader + ">");
log.info("isRemoveCacheRequestHeader=<" + isRemoveCacheRequestHeader + ">");
log.info("samplerStartNumber=<" + samplerStartNumber + ">");
log.info("samplerStartNumber=<" + samplerStartNumber + ">");
log.info("****************************************");

HarForJMeter.generateJmxAndRecord(fileHarIn, fileJmxOut,createNewTransactionAfterRequestMs,isAddPause, isRemoveCookieHeader, isRemoveCacheRequestHeader, regexFilterInclude, regexFilterExclude, recordXmlOut);
HarForJMeter.generateJmxAndRecord(fileHarIn, fileJmxOut,createNewTransactionAfterRequestMs,isAddPause, isRemoveCookieHeader, isRemoveCacheRequestHeader, regexFilterInclude, regexFilterExclude, recordXmlOut, pageStartNumber, samplerStartNumber);

log.info("After HarForJMeter.generateJmxAndRecord");
btConvert.setEnabled(true);
Expand Down Expand Up @@ -269,9 +300,21 @@ private JPanel createFilterAndPausePanel() {
JLabel pauseBetweenUrlLabel = new JLabel("(Optional) Time (ms) between 2 URLs to create a new page (Transaction Controller)");
pauseBetweenUrlTextField = new JTextField("5000", 80);

JLabel pageStartNumberLabel = new JLabel("(Optional) Page start number usually for partial recording (default 1)");
pageStartNumberTextField = new JTextField("", 80);

JLabel samplerStartNumberLabel = new JLabel("(Optional) Sampler start number usually for partial recording (default 1)");
samplerStartNumberTextField = new JTextField("", 80);

panel.add(pauseBetweenUrlLabel);
panel.add(pauseBetweenUrlTextField);

panel.add(pageStartNumberLabel);
panel.add(pageStartNumberTextField);

panel.add(samplerStartNumberLabel);
panel.add(samplerStartNumberTextField);

panel.add(regexFilterIncludeLabel);
panel.add(regexFilterIncludeField);

Expand Down

0 comments on commit f255778

Please sign in to comment.