# Gatling and a HTML5 app running against SAP

**URL:** <https://community.gatling.io/t/gatling-and-a-html5-app-running-against-sap/2319>\
**Category:** Gatling (Open-Source)\
**Created:** [May 26, 2015, 1:08pm UTC](https://community.gatling.io/t/gatling-and-a-html5-app-running-against-sap/2319 "2015-05-26T13:08:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fugmag](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fugmag](https://community.gatling.io/u/fugmag)\
**Post date:** [May 26, 2015, 1:08pm UTC](https://community.gatling.io/t/gatling-and-a-html5-app-running-against-sap/2319/1 "2015-05-26T13:08:56Z")

</div>

I have been given the great task of trying generate a Gatling script against a HTML5 app that queries SAP.  
Using Gatling recorder I have achieved the following script:

`

**package [no.STORE](http://no.coop/)**

**import** scala.concurrent.duration.\_

**import** io.gatling.core.Predef.\_

**import** io.gatling.http.Predef.\_

**import** io.gatling.jdbc.Predef.\_

**class** RecordedSimulation  
**extends** Simulation {

**val** _httpProtocol_ = _http_

.baseURL(**“[http://STOREq30.sds.STORE.no:8300](http://coopq30.sds.coop.no:8300/)”**)

.inferHtmlResources()

.acceptHeader( **"application/json,**  
**text/javascript, _/_; q=0.01"** )

.acceptEncodingHeader( **“gzip, deflate”** )

.acceptLanguageHeader( **“en-US,en;q=0.5”** )

.authorizationHeader( **“Basic ZXh0bWFmdTpDb29wNzg=”** )

.connection( **“keep-alive”** )

.contentTypeHeader( **“application/x-www-form-urlencoded; charset=UTF-8”** )

.userAgentHeader( **"Mozilla/5.0**  
**(Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0"**)

**val** _headers\_0_ = _Map_( **“Accept”** → **“text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8”** )

**val** _headers\_2_ = _Map_( **“Accept”** → **“_/_”** )

**val** _headers\_3_ = _Map_( **“Accept”** → **“text/css,_/_;q=0.1”** )

**val** _headers\_6_ = _Map_(

**"Access-Control-Allow-Origin"**  
 → **“\*”** ,

**"NeptuneServer"**  
 → **“[http://STOREq30.sds.STORE.no:8300](http://coopq30.sds.coop.no:8300/)”**,

**"Pragma"**  
 → **“no-cache”** ,

**"X-Requested-With"**  
 → **“XMLHttpRequest”** ,

**"X-SUP-APPCID"**  
 → **“5befbe04-146f-46c7-b052-30a7034b98b5”** ,

**"sap-client"**  
 → **“300”** )

**val** _headers\_10_ = _Map_(

**"Accept"**  
 → **"text/plain, _/_;**  
**q=0.01"** ,

**"Access-Control-Allow-Origin"**  
 → **“\*”** ,

**"NeptuneServer"**  
 → **“[http://STOREq30.sds.STORE.no:8300](http://coopq30.sds.coop.no:8300/)”**,

**"X-Requested-With"**  
 → **“XMLHttpRequest”** ,

**"X-SUP-APPCID"**  
 → **“5befbe04-146f-46c7-b052-30a7034b98b5”** ,

**"sap-client"**  
 → **“300”** )

**val** _uri1_ = **"[http://STOREq30.sds.STORE.no:8300](http://coopq30.sds.coop.no:8300/)"**

**val** _scn_ = _scenario_( **“RecordedSimulation”** )

.exec(_http_( **“baseURL”** )

.get( **"/neptune/UI5\_RETAIL\_APPCACHE?sap-client=300&appcache=STORE\_Q30\_DIREKTE"** )

.headers(_headers\_0_)

.check([_status_.is](http://status.is/)(401)))

.pause(3)

.exec(_http_( **“request\_1”** )

.get( **"/neptune/UI5\_RETAIL\_APPCACHE?sap-client=300&appcache=STORE\_Q30\_DIREKTE"** )

.headers(_headers\_0_)

.basicAuth( **“username”** , **“Password”** )

.resources(_http_( **“request\_2”** )

.get(_uri1_ +  
**"/neptune/server/openui5/resources/sap-ui-core.js?v=1.26.3"** )

.headers(_headers\_2_)

.basicAuth( **“username”** , **“Password”** )

.check([_status_.is](http://status.is/)(304)),

_http_( **“request\_3”** )

.get(_uri1_ +  
**"/neptune/public/application/ui5\_retail\_appcache/css/app.css"** )

.headers(_headers\_3_)

.basicAuth( **“username”** , **“Password”** )

.check([_status_.is](http://status.is/)(304)),

_http_( **“request\_4”** )

.get(_uri1_ +  
**"/favicon.ico"** )

.headers(_headers\_0_)

.check([_status_.is](http://status.is/)(404)),

_http_( **“request\_5”** )

.get(_uri1_ +  
**"/favicon.ico"** )

.headers(_headers\_0_)

.check([_status_.is](http://status.is/)(404))))

.pause(7)

.exec(_http_( **“request\_6”** )

.post( **"/neptune/neptune\_ajax?ajax\_id=GET\_APP\_DATA&ajax\_applid=UI5\_RETAIL\_APPCACHE&field\_id=00006&ajax\_value=STORE\_Q30\_DIREKTE"** )

.headers(_headers\_6_)

.formParam(**"""[{“APPLID”:“UI5\_RETAIL\_APPCACHE\_PASSCODE”,“LANGUAGE”:“E”,“UPDDAT”:“20150508”,“UPDTIM”:“124703”,“INVALID”:false,“DESCR”:“STORE”},{“APPLID”:“UI5\_RETAIL\_APPCACHE\_MENU”,“LANGUAGE”:“E”,“UPDDAT”:“20150518”,“UPDTIM”:“160452”,“INVALID”:false,“DESCR”:“STORE”},{“APPLID”:“UI5\_RETAIL\_CREATE\_PO”,“LANGUAGE”:“E”,“UPDDAT”:“20150522”,“UPDTIM”:“165356”,“INVALID”:false,“DESCR”:“STORE”},{“APPLID”:“UI5\_RETAIL\_TRANSACTIONS”,“LANGUAGE”:“E”,“UPDDAT”:“20150522”,“UPDTIM”:“154137”,“INVALID”:false,“DESCR”:“STORE”}]"""**,  
**""** )

.basicAuth( **“username”** , **“Password”** )

.resources(_http_( **“request\_7”** )

.post(_uri1_ +  
**"/neptune/native/neptune\_ajax?ajax\_id=GET\_MENU\_LIST&ajax\_applid=UI5\_RETAIL\_APPCACHE\_MENU&field\_id=00044&ajax\_value=STORE\_Q30\_DIREKTE"** )

.headers(_headers\_6_)

.formParam( **"""{“TXT\_HEADER”:"STORE**  
**ONE BYGG TROMSØ, NORD (2371)",“TXT\_LIST”:“Transaksjoner”,“ENABLE\_LIST”:true,“PARENT”:“000C291EE8241EE4B8D030DED8CA03EC”,“PREVIOUS”:“00000000000000000000000000000000”}"""**,  
**""** )

.basicAuth( **“username”** , **“Password”** ),

_http_( **“request\_8”** )

.post(_uri1_ +  
**"/neptune/native/neptune\_ajax?ajax\_id=&ajax\_applid=UI5\_RETAIL\_APPCACHE\_MENU&field\_id=00085&ajax\_value=undefined"** )

.headers(_headers\_6_)

.basicAuth( **“username”** , **“Password”** ),

_http_( **“request\_9”** )

.post(_uri1_ +  
**"/neptune/native/neptune\_ajax?ajax\_id=GET\_STORE\_DETAILS&ajax\_applid=UI5\_RETAIL\_APPCACHE\_MENU&field\_id=00075&ajax\_value=undefined"** )

.headers(_headers\_6_)

.formParam( **"""{“TXT\_HEADER”:"STORE**  
**ONE BYGG TROMSØ, NORD**  
**(2371)",“TXT\_LIST”:“Transaksjoner”,“ENABLE\_LIST”:true,“PARENT”:“000C291EE8241EE4B8D030DED8CA03EC”,“PREVIOUS”:“00000000000000000000000000000000”}||{“WERKS”:“2371”,“NAME1”:"STORE**  
**ONE BYGG TROMSØ,**  
**NORD",“LIST\_ID”:“1432318827898”,“MATNR”:"",“MATNR\_TIMEOUT”:"",“TILE\_TITLE”:“Reklamasjon”,“TRANSACTION\_TYPE”:“ReturnDefectItem”,“WERKS\_TIMEOUT”:“1432318822715”,“FORCE\_OFFLINE”:false,“DISABLE\_HAPTIC”:false,“REASON\_TIMEOUT”:“1432318822715”}"""** ,  
**""** )

.basicAuth( **“username”** , **“Password”** )))

.pause(7)

.exec(_http_( **“request\_10”** )

.get( **"/neptune/server/openui5/resources/sap/suite/ui/commons/messagebundle\_no.properties"** )

.headers(_headers\_10_)

.basicAuth( **“username”** , **“Password”** )

.resources(_http_( **“request\_11”** )

.post(_uri1_ +  
**"/neptune/native/neptune\_ajax?ajax\_id=DUMMY\_NETWORK\_CHECK&ajax\_applid=UI5\_RETAIL\_CREATE\_PO&field\_id=00505&ajax\_value=undefined"** )

.headers(_headers\_6_)

.basicAuth( **“username”** , **“Password”** ),

_http_( **“request\_12”** )

.post(_uri1_ +  
**"/neptune/native/neptune\_ajax?ajax\_id=GET\_CARTS\_TOTAL&ajax\_applid=UI5\_RETAIL\_CREATE\_PO&field\_id=00309&ajax\_value=undefined"** )

.headers(_headers\_6_)

.formParam( **"""{“WERKS”:“2371”,“NAME1”:"STORE**  
**ONE BYGG TROMSØ, NORD"}"""** , **“”** )

.basicAuth( **“username”** , **“Password”** ),

_http_( **“request\_13”** )

.post(_uri1_ +  
**"/neptune/native/neptune\_ajax?ajax\_id=INITIALIZE\_PALLET\_MASTER&ajax\_applid=UI5\_RETAIL\_CREATE\_PO&field\_id=00525&ajax\_value=undefined"** )

.headers(_headers\_6_)

.basicAuth( **“username”** , **“Password”** ),

_http_( **“request\_14”** )

.post(_uri1_ +  
**"/neptune/native/neptune\_ajax?ajax\_id=INITIALIZE\_MATERIAL\_MASTER&ajax\_applid=UI5\_RETAIL\_CREATE\_PO&field\_id=00311&ajax\_value=undefined"** )

.headers(_headers\_6_)

.formParam( **"{}"** ,  
**""** )

.basicAuth( **“username”** , **“Password”** )))

.pause(57)

.exec(_http_( **“request\_15”** )

.post( **"/neptune/native/neptune\_ajax?ajax\_id=DUMMY\_NETWORK\_CHECK&ajax\_applid=UI5\_RETAIL\_CREATE\_PO&field\_id=00505&ajax\_value=undefined"** )

.headers(_headers\_6_)

.basicAuth( **“username”** , **“Password”** )

.resources(_http_( **“request\_16”** )

.post(_uri1_ +  
**"/neptune/native/neptune\_ajax?ajax\_id=GET\_ARTICLE\_DETAILS&ajax\_applid=UI5\_RETAIL\_CREATE\_PO&field\_id=00055&ajax\_value=123456789"** )

.headers(_headers\_6_)

.formParam( **"""{“WERKS”:“2371”,“NAME1”:"STORE**  
**ONE BYGG TROMSØ, NORD",“LIST\_ID”:1432643830663,“TOTAL\_LISTS”:“14”,“DEVICE\_ID”:“usernamewin8ff38”}||{}||{}||{}"""** ,  
**""** )

.basicAuth( **“username”** , **“Password”** )))

setUp(_scn_.inject(atOnceUsers(1))).protocols(_httpProtocol_)

}

`

My question is would gatling work with this technology? a HTML5 app using ajax-calls? Looking at the script it seams like this should work and replaying it does not gives me any errors.  
Just to generate load, maybe this would work? Or do I need to use a tool that actually uses the entire DOM to test HTML5.  
BTW: The HTML5 app runs through Soti Mobicontrol.

Cheers

---

<div class="post-metadata">

**Author:** ![notdryft](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/notdryft/32/1103_2.png) [@notdryft](https://community.gatling.io/u/notdryft)\
**Post date:** [May 26, 2015, 1:25pm UTC](https://community.gatling.io/t/gatling-and-a-html5-app-running-against-sap/2319/2 "2015-05-26T13:25:51Z")

</div>

Hi,

You can’t perform a load test on a javascript application with Gatling. You can however reproduce it’s ajax calls and do a load test on it’s backend, which is what your script is doing and what you recorded.

If this was your intention, sure, it will work!

Cheers,  
Guillaume.

---

<div class="post-metadata">

**Author:** ![fugmag](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fugmag](https://community.gatling.io/u/fugmag)\
**Post date:** [May 26, 2015, 1:45pm UTC](https://community.gatling.io/t/gatling-and-a-html5-app-running-against-sap/2319/3 "2015-05-26T13:45:39Z")

</div>

Ok, thanx Guillaume!  
I want to crate traffic on the backend (using the frontend)  
Just a control question:

given a part of my script:

`  
.post(_uri1_ +  
**"/neptune/native/neptune\_ajax?ajax\_id=GET\_CARTS\_TOTAL&ajax\_applid=UI5\_RETAIL\_CREATE\_PO&field\_id=00309&ajax\_value=undefined"** )

`

This http-post will actually create load by executing some ajax-call that will hit the backend, which is my intention.

//Magnus
