# How to use four csv files in login object?

**URL:** <https://community.gatling.io/t/how-to-use-four-csv-files-in-login-object/1385>\
**Category:** Gatling (Open-Source)\
**Created:** [September 9, 2014, 8:33am UTC](https://community.gatling.io/t/how-to-use-four-csv-files-in-login-object/1385 "2014-09-09T08:33:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tracy\_Zhao](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@Tracy\_Zhao](https://community.gatling.io/u/Tracy_Zhao)\
**Post date:** [September 9, 2014, 8:33am UTC](https://community.gatling.io/t/how-to-use-four-csv-files-in-login-object/1385/1 "2014-09-09T08:33:38Z")

</div>

My question as followed:  
I created 10 users to logon one system, but system check duplicate user, if one user logon system, next logon for the same user will be automatically log out.  
I will test compound scenarios using 10 users.  
I separate 10 users from one file to 4 files.  
user and password in csv file.  
2 users in 1.csv  
3 users in 2.csv  
2 users in 3.csv  
3 users in 4.csv  
when running the following script, error pops up.

1. how to handle multiple files in login function?
2. If above handle is incorrect, do you have other good advice?

Class CompoundPage extends Simulation {

val headers\_0 = Map(  
“”“Accept”"" → “”“text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,_/_;q=0.8"”",  
“”“Cache-Control”"" → “”“max-age=0"”")

val headers\_1 = Map(  
“”“Accept”"" → “”“text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,_/_;q=0.8"”",  
“”“Cache-Control”"" → “”“max-age=0"”",  
“”“Content-Type”"" → “”“application/x-www-form-urlencoded”"",  
“”“Origin”"" → “”“[https://portal-qa1.everbridge.net](https://portal-qa1.everbridge.net)”"")

val headers\_2 = Map(  
“”“Accept”"" → “”“text/css,_/_;q=0.1"”",  
“”“Cache-Control”"" → “”“max-age=0"”")

val headers\_79 = Map(""“Accept”"" → “”“text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,_/_;q=0.8"”")

val contactuserinQA = csv(“1.csv”).circular  
val notificationuserinQA = csv(“2.csv”).circular  
val universeuserinQA = csv(“3”).circular  
val dashboarduserinQA = csv(“4.csv”).circular

var logintype=""  
def userInQAorStage(logintype: String) : io.gatling.core.feeder.FeederBuilder[\_] = {  
if(scenParse.baseurl.contains(“[portal-qa1.everbridge.net](http://portal-qa1.everbridge.net)”)) {  
if (logintype.contains(“contact”)){  
contactuserinQA  
}  
else if (logintype.contains(“notification”)){  
notificationuserinQA  
}  
else if (logintype.contains(“universe”)){  
universeuserinQA  
}  
else if (logintype.contains(“dashboard”)){  
dashboarduserinQA  
}  
}  
else userInStage  
}

object object Login{  
def login(logintype:String) = {  
exec(http(“request\_0”)  
.get("""/login""")  
.headers(headers\_0))  
.pause(2)  
.feed(userInQAorStage(logintype))

.exec(http(“request\_1”)  
.post("""/check""")  
.headers(headers\_1)  
.formParam(""“nc4Sourse”"", “”"""")  
.formParam(""“nc4"”", “”"""")  
.formParam(""“username”"", “${user}”)  
.formParam(""“password”"", “${password}”)  
.formParam(""“input1"”", “”“English (United States)”"")  
.resources(http(“request\_2”)  
.get(uri1 + “”"/statics/stylesheets/jscss/ajax.css?version=V3.1.1-2014-08-28%2002:18:43""")  
.headers(headers\_2)  
.check(status.is(200))  
}

object Logout {  
val logout = group(“Logout”){  
exec(http(“request\_204”)  
.get("""/logout""")  
.headers(headers\_79)  
.check(status.is(200)))  
}  
}

val logincontact = scenario(“ContacLogin”).repeat(5){  
exec(Login.login(“contact”), Logout.logout)  
}  
setUp(scn.inject(atOnceUsers(2))).protocols(httpProtocol)

}

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [September 9, 2014, 1:25pm UTC](https://community.gatling.io/t/how-to-use-four-csv-files-in-login-object/1385/2 "2014-09-09T13:25:10Z")

</div>

I’m not sure I get it right, but it looks like you could have one single scenario definition where you pass the feeder name, and then have multiple concurrent scenario instances:

def scn(feederName: String) = scenario(“foo”)…feed(csv(feederName))…

setUp(  
scn(“file1.csv”).inject(atOnceUsers(2)),  
scn(“file2.csv”).inject(atOnceUsers(2)),

scn(“file3.csv”).inject(atOnceUsers(2)),

scn(“file4.csv”).inject(atOnceUsers(2))

).protocols(httpProtocol)

---

<div class="post-metadata">

**Author:** ![Tracy\_Zhao](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@Tracy\_Zhao](https://community.gatling.io/u/Tracy_Zhao)\
**Post date:** [September 10, 2014, 7:12am UTC](https://community.gatling.io/t/how-to-use-four-csv-files-in-login-object/1385/3 "2014-09-10T07:12:06Z")

</div>

Hi Stéphane,  
Thank you very much, you suggested single scenario definition can work well for me.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [September 10, 2014, 7:30am UTC](https://community.gatling.io/t/how-to-use-four-csv-files-in-login-object/1385/4 "2014-09-10T07:30:06Z")

</div>

Glad it helped 🙂

---

<div class="post-metadata">

**Author:** ![Bala\_Krishnan](https://avatars.discourse-cdn.com/v4/letter/b/58956e/32.png) [@Bala\_Krishnan](https://community.gatling.io/u/Bala_Krishnan)\
**Post date:** [July 29, 2019, 1:55pm UTC](https://community.gatling.io/t/how-to-use-four-csv-files-in-login-object/1385/5 "2019-07-29T13:55:30Z")

</div>

Hi Stephane,

I have tried with the scenario which you have mentioned, but I’m getting an error as "Scenario names must be unique but found duplicates: ".

Can you please look into this.

The scenario you mentioned:

def scn(feederName: String) = scenario(“foo”)…feed(csv(feederName))…

setUp(  
scn(“file1.csv”).inject(atOnceUsers(2)),  
scn(“file2.csv”).inject(atOnceUsers(2)),

scn(“file3.csv”).inject(atOnceUsers(2)),

scn(“file4.csv”).inject(atOnceUsers(2))

).protocols(httpProtocol)

Thanks
