java - Multi user file property Selenium -
i made autotest on selenium. test start on jmeter load testing 10, 20, 50+ users. should do. create property file (configuration file) , put there url, login, password. made cycle , put there code i'll start browser, login, visit link, logout , quit. here's have in property file:
url:http://barracuda-qa.ko.kodak.com/d2l/faces/login.jsp login:test1, test2, tesr3 password:abc123
here's code in java:
public class testmultiply extends testcase { file file = new file("c:/barracuda/prop.properties"); private fileinputstream fileinput = null; private webdriver driver; public firefoxprofile profile = new firefoxprofile(); public int index=0; public testmultiply(){} public testmultiply(string testname){ super(testname); } @before public void setup() throws exception { super.setup(); } @test public void testtestload() throws interruptedexception { try { fileinput = new fileinputstream(file); } catch (filenotfoundexception e) { e.printstacktrace(); } properties prop = new properties(); try { prop.load(fileinput); } catch (ioexception e) { e.printstacktrace(); } driver = new firefoxdriver(); (int i= 0; i<prop.getproperty("login").length(); i++){ //string login = prop.getproperty("login"+i); thread t1 = new thread(new runnable() { @override public void run() { driver = new firefoxdriver(); driver.get(prop.getproperty("url")); driver.findelement(by.id("loginform:authlogin")).sendkeys(login); driver.findelement(by.id("loginform:authpassword")).sendkeys(prop.getproperty(key)); driver.manage().timeouts().implicitlywait(60, timeunit.seconds); driver.findelement(by.id("loginform:btnlogin")).click(); driver.manage().timeouts().implicitlywait(2000, timeunit.seconds); driver.findelement(by.id("settingslink")); driver.manage().timeouts().implicitlywait(2000, timeunit.seconds); driver.findelement(by.xpath("//a[@class='logout']")).click(); driver.quit(); } }); t1.start(); thread.sleep(10000); } } @after public void teardown() throws exception { super.teardown(); } }
i need make cycle multylogin. should in cycle in login field paste 1 login property file same password users. example property file have structure:
url:http://barracuda-qa.ko.kodak.com/d2l/faces/login.jsp login:test1, test2 password:abc123
so should start browser 2 times , it'll login test1 - abc123 , test2 - abc123.
so should start browser 2 times , it'll login test1 - abc123 , test2 - abc123.
in short need (login) comma separated string properties file, split , keep in list. use in loop.
list<string> items = arrays.aslist(config.getproperty("login").split("\\s*,\\s*"));
above code should give needed list , can implement multiple login given below:
for (int i=0; i<items.size(); i++){ driver.get(config.getproperty("url")); //here goes multiple user name usernameeditbox.sendkeys(items.get(i).trim()); //here same password passwordeditbox.sendkeys(config.getproperty("password")); signinbutton.click(); logout.click(); }
you can check full class view here: clickme
Comments
Post a Comment