I have a web application which I need to test whether it can simulate user behavior for many users logged in at the same time and perform multiple file uploads and downloads. There are multiple entry points for the uploads as well as downloads. I went ahead with using Selenium for imitating user behavior. Integrated Java, Selenium, TestNG, AutoIT and also using Selenium Grid to connect to various VMs for browser compatibility testing. Browsers supported are Chrome, Firefox, IE 8,9,10,11. Everything works fine except the handling of windows dialogs in parallel. Any tool that I came across which handles windows dialogs requires the window to be in the front. This is not possible when I am running say 100 instances. Please suggest.
I am adding the code snippets. They wont run because they are configured for Selenium Grid.
Here is my 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 to 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 you can see, the
Runtime.getRuntime().exec("C:\IE11.exe");
runs the AutoIt script. The AutoIt script simply contains:
Send("!s")
This just sends Alt+S (command to save in IE download pop up bar). And this is the area where parallel execution fails.
Here is my 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>