i have web application need test whether can simulate user behavior many users logged in @ same time , perform multiple file uploads , downloads. there multiple entry points uploads downloads. went ahead using selenium imitating user behavior. integrated java, selenium, testng, autoit , using selenium grid connect various vms browser compatibility testing. browsers supported chrome, firefox, ie 8,9,10,11. works fine except handling of windows dialogs in parallel. tool came across handles windows dialogs requires window in front. not possible when running 100 instances. please suggest.
i adding code snippets. wont run because configured selenium grid.
here java class:
public class test { remotewebdriver driver; @test public void testdownload() { driver.findelement(by.id("download")).click(); runtime.getruntime().exec("c:\\ie11.exe"); } @beforetest @parameters({"browser","version","environment","username","password"}) public void launchbrowserandlogin(string browser, string version, string environment, string username, string password) throws malformedurlexception, interruptedexception { desiredcapabilities caps = new desiredcapabilities(); if(browser.equalsignorecase("chrome")){ system.setproperty("webdriver.chrome.driver", "c://chromedriver.exe"); caps = desiredcapabilities.chrome(); } if(browser.equalsignorecase("ie")){ system.setproperty("webdriver.ie.driver", "c://iedriverserver.exe"); caps = desiredcapabilities.internetexplorer(); caps.setversion(version); } switch(environment){ case "trunk" : baseurl = "http://trunk-url"; break; case "prod" : baseurl = "https://prod-url"; break; default : baseurl = ""; break; } driver = new remotewebdriver(new url("http://localhost/wd/hub"), caps); driver.navigate().to(baseurl); //go selected url driver.manage().window().maximize(); //maximize window thread.sleep(7000); driver.findelement(by.xpath(".//*[@id='username']")).sendkeys(username); //enter username driver.findelement(by.xpath(".//*[@id='password']")).sendkeys(password); //enter password driver.findelement(by.xpath(".//*[@id='login']")).click(); //click on login thread.sleep(7000); assert.assertequals(driver.gettitle(), "order history"); } @aftertest public void logoutandterminatebrowser() throws interruptedexception { driver.findelement(by.xpath(".//*[@id='login-menu']/a")).click(); //click on logout thread.sleep(7000); driver.quit(); } }
as can see,
runtime.getruntime().exec("c:\ie11.exe");
runs autoit script. autoit script contains:
send("!s")
this sends alt+s (command save in ie download pop bar). , area parallel execution fails.
here testng xml:
<?xml version="1.0" encoding="utf-8"?> <!doctype suite system "http://testng.org/testng-1.0.dtd"> <suite name="testsuite" verbose="2" parallel="tests" thread-count="2"> <test name="ie11_1"> <parameter name="browser" value="ie"/> <parameter name="version" value="11"/> <parameter name="environment" value="trunk"/> <parameter name="username" value="user1"/> <parameter name="password" value="pass1"/> <classes><class name="test"/></classes> </test> <test name="ie11_2"> <parameter name="browser" value="ie"/> <parameter name="version" value="11"/> <parameter name="environment" value="trunk"/> <parameter name="username" value="user2"/> <parameter name="password" value="pass2"/> <classes><class name="test"/></classes> </test>
i circumvent windows dialogs altogether , simulate network traffic on backend using http requests.
use fiddler2 capture exact traffic, parameterize it, , voila.
i have example of on post, 1 sec:
copied previous answer on question here:
selenium webdriver doesn't support this. interacting non-browser windows (such native file upload dialogs , basic auth dialogs) has been topic of discussion on webdriver discussion board, there has been little no progress on subject.
i have, in past, been able work around capturing underlying request tool such fiddler2, , sending request specified file attached byte blob.
if need cookies authenticated session, webdriver.magage().getcookies() should in aspect.
edit: have code somewhere worked, i'll see if can ahold of can use.
public rosterpage uploadrosterfile(string filepath){ face().log("importing roster..."); loginrequest login = new loginrequest(); login.username = prefs.emaillogin; login.password = prefs.passwordlogin; login.rememberme = false; login.forward = ""; login.schoolid = ""; //set request data string url = "http://www.foo.bar.com" + "/manageroster/uploadroster"; string javascript = "return $('#seasons li.selected') .attr('data-season-id');"; string seasonid = (string)((ijavascriptexecutor)driver().getbasedriver()).executescript(javascript); javascript = "return foo.bar.data.selectedteamid;"; string teamid = (string)((ijavascriptexecutor)driver().getbasedriver()).executescript(javascript); //send request , parse response new driver url multipartform form = new multipartform(url); form.setfield("teamid", teamid); form.setfield("seasonid", seasonid); form.sendfile(filepath,loginrequest.sendloginrequest(login)); string response = form.responsetext.tostring(); string newurl = staticbasetestobjs.removestringsubstring("http://www.foo.bar.com" + response.split('"')[1].split('"')[0],"amp;"); face().log("navigating url: "+ newurl); driver().goto(new uri(newurl)); return this; }
where multipartform is: multipartform
and loginrequest/response: loginrequest loginresponse
the code above in c#, there equivalent base classes in java need them mimic functionality.
the important part of of code multipartform.sendfile method, magic happens.