IE8/IE9 parallel execution issue

81 views
Skip to first unread message

Payal Gupta

unread,
May 15, 2012, 2:09:05 AM5/15/12
to seleniu...@googlegroups.com, webd...@googlegroups.com
Hi All,

When I try to do the parallel execution on 3 virtual machines ( 2 IE8 browser and 1 IE9 browser).

I get the following exception :
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWork
er.java:125)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.openqa.selenium.WebDriverException: Session [1337056011738] not a
vailable - []
Command duration or timeout: 1.81 seconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-28 15:00:40'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.vers
ion: '1.6.0_16'
Driver info: driver.version: RemoteWebDriver
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.
java:170)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHa
ndler.java:123)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.ja
va:438)
        at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:2
00)
        at org.openqa.selenium.internal.seleniumemulation.Open.handleSeleneseCom
mand(Open.java:36)
        at org.openqa.selenium.internal.seleniumemulation.Open.handleSeleneseCom
mand(Open.java:22)
        at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(
SeleneseCommand.java:33)
        ... 21 more
Caused by: org.openqa.grid.common.exception.GridException: Session [133705601173
8] not available - []
        at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHan
dler.java:163)
        at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:
81)
        at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:6
7)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.jav
a:428)
        at org.openqa.jetty.jetty.servlet.WebApplicationHandler.dispatch(WebAppl
icationHandler.java:473)

Running Test Cases Count: 0
Running Failed: 0
Running Passed: 0
        at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.j
ava:568)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
        at org.openqa.jetty.jetty.servlet.WebApplicationContext.handle(WebApplic
ationContext.java:633)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
        at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
        at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)

        at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:9
86)
        at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
        at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.
java:243)
        at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
        at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
java.io.IOException: Stream closed
        at java.io.BufferedWriter.ensureOpen(BufferedWriter.java:98)
        at java.io.BufferedWriter.write(BufferedWriter.java:203)
        at java.io.Writer.write(Writer.java:140)
        at com.########.studios.dsaa.qa.util.ReportHTML.writeTrailer(ReportHTML.ja
va:153)
        at com.########.studios.dsaa.qa.util.Report.close(Report.java:141)
        at com.########.studios.dsaa.qa.scenarios.DSAARun.processTestCases(DSAARun
.java:431)
        at com.########.studios.dsaa.qa.scenarios.RunTestScenario.runScenario(RunT
estScenario.java:34)
        at com.########.studios.dsaa.qa.scenarios.TestW7IE9.testBrowser3(TestW7IE9
.java:33)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocat
ionHelper.java:74)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:673)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWork
er.java:125)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:619)
java.io.IOException: Stream closed
        at java.io.BufferedWriter.ensureOpen(BufferedWriter.java:98)
        at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:108)
        at java.io.BufferedWriter.flush(BufferedWriter.java:235)
        at com.########.studios.dsaa.qa.util.Report.close(Report.java:142)
        at com.########.studios.dsaa.qa.scenarios.DSAARun.processTestCases(DSAARun
.java:431)
        at com.########.studios.dsaa.qa.scenarios.RunTestScenario.runScenario(RunT
estScenario.java:34)
        at com.########.studios.dsaa.qa.scenarios.TestW7IE9.testBrowser3(TestW7IE9
.java:33)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocat
ionHelper.java:74)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:673)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWork
er.java:125)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:619)
java.io.IOException: Stream closed
        at java.io.BufferedWriter.ensureOpen(BufferedWriter.java:98)
        at java.io.BufferedWriter.write(BufferedWriter.java:203)
        at java.io.Writer.write(Writer.java:140)
        at com.########.studios.dsaa.qa.util.ReportHTML.writeTrailer(ReportHTML.ja
va:153)
        at com.########.studios.dsaa.qa.util.Report.close(Report.java:141)
        at com.########.studios.dsaa.qa.scenarios.DSAARun.processTestCases(DSAARun
.java:434)
        at com.########.studios.dsaa.qa.scenarios.RunTestScenario.runScenario(RunT
estScenario.java:34)
        at com.########.studios.dsaa.qa.scenarios.TestW7IE9.testBrowser3(TestW7IE9
.java:33)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocat
ionHelper.java:74)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:673)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWork
er.java:125)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:619)
java.io.IOException: Stream closed
        at java.io.BufferedWriter.ensureOpen(BufferedWriter.java:98)
        at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:108)
        at java.io.BufferedWriter.flush(BufferedWriter.java:235)
        at com.########.studios.dsaa.qa.util.Report.close(Report.java:142)
        at com.########.studios.dsaa.qa.scenarios.DSAARun.processTestCases(DSAARun
.java:434)
        at com.########.studios.dsaa.qa.scenarios.RunTestScenario.runScenario(RunT
estScenario.java:34)
Total Test Cases: 0
Failed: 0
Passed: 0

Running Test Cases Count: 0
Running Failed: 0
Running Passed: 0
        at com.########.studios.dsaa.qa.scenarios.TestW7IE9.testBrowser3(TestW7IE9
.java:33)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocat
ionHelper.java:74)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:673)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWork
er.java:125)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:619)
org.openqa.selenium.WebDriverException: Session [1337056011738] not available -
[]
Command duration or timeout: 811 milliseconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-28 15:00:40'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.vers
ion: '1.6.0_16'
Driver info: driver.version: RemoteWebDriver
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.
java:170)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHa
ndler.java:123)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.ja
va:438)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.ja
va:442)
        at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:
318)
        at org.openqa.selenium.WebDriverCommandProcessor.stop(WebDriverCommandPr
ocessor.java:110)
        at com.thoughtworks.selenium.DefaultSelenium.stop(DefaultSelenium.java:1
39)
        at com.########.studios.dsaa.qa.RemoteController.tearDown(RemoteController
.java:154)
        at com.########.studios.dsaa.qa.scenarios.RunTestScenario.runScenario(RunT
estScenario.java:35)
        at com.########.studios.dsaa.qa.scenarios.TestW7IE9.testBrowser3(TestW7IE9
.java:33)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocat
ionHelper.java:74)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:673)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWork
er.java:125)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.openqa.grid.common.exception.GridException: Session [133705601173
8] not available - []
        at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHan
dler.java:163)
        at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:
81)
        at org.openqa.grid.web.servlet.DriverServlet.doDelete(DriverServlet.java
:73)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.jav
a:428)
        at org.openqa.jetty.jetty.servlet.WebApplicationHandler.dispatch(WebAppl
icationHandler.java:473)
        at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.j
ava:568)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
        at org.openqa.jetty.jetty.servlet.WebApplicationContext.handle(WebApplic
ationContext.java:633)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
        at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
        at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)

        at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:9
86)
        at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
        at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.
java:243)
        at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
        at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 495.302 sec

Results :

Tests run: 3, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8:23.044s
[INFO] Finished at: Tue May 15 11:18:39 GMT+05:30 2012
[INFO] Final Memory: 3M/8M
[INFO] ------------------------------------------------------------------------

I have checked the the logs at hubs too :
HUB 1 :
22:45:45.788 INFO - Done: /status
22:45:50.788 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
bc38d3 at URL: /status)
22:45:50.788 INFO - Done: /status
22:45:55.788 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
68c0ec3 at URL: /status)
22:45:55.803 INFO - Done: /status
22:46:00.803 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
6d108a97 at URL: /status)
22:46:00.803 INFO - Done: /status
22:46:05.803 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
448b495a at URL: /status)
22:46:05.803 INFO - Done: /status
22:46:09.881 INFO - Executing: [delete session: 1337056011738] at URL: /session/
1337056011738)

22:46:10.116 INFO - Done: /session/1337056011738
22:46:10.819 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
846692c at URL: /status)
22:46:10.819 INFO - Done: /status
22:46:15.819 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
69fba118 at URL: /status)
22:46:15.819 INFO - Done: /status
22:46:20.834 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
62ed3a at URL: /status)
22:46:20.834 INFO - Done: /status
22:46:25.834 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@


HUB 2 :
5e3c378b at URL: /status)
22:45:59.753 INFO - Done: /status
22:46:04.769 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
5dd06de at URL: /status)
22:46:04.769 INFO - Done: /status
22:46:09.769 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
36fb3414 at URL: /status)
22:46:09.769 INFO - Done: /status
22:46:14.785 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
7c3bfaa2 at URL: /status)
22:46:14.785 INFO - Done: /status
22:46:15.910 INFO - Executing: [delete session: 1337056217522] at URL: /session/
1337056217522)

22:46:16.113 INFO - Done: /session/1337056217522
22:46:19.785 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
1bfde48c at URL: /status)
22:46:19.785 INFO - Done: /status
22:46:24.785 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
308275bb at URL: /status)
22:46:24.800 INFO - Done: /status
22:46:29.800 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
5a30b235 at URL: /status)
22:46:29.800 INFO - Done: /status
22:46:34.800 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
4462cf1d at URL: /status)


HUB 3 :
2:46:01.327 INFO - Done: /status
2:46:06.327 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
6bf7916 at URL: /status)
2:46:06.327 INFO - Done: /status
2:46:11.327 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
478a2d at URL: /status)
2:46:11.327 INFO - Done: /status
2:46:16.342 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
6c1186f at URL: /status)
2:46:16.342 INFO - Done: /status
2:46:20.155 INFO - Executing: [delete session: 1337059964455] at URL: /session/
337059964455)

2:46:20.452 INFO - Done: /session/1337059964455
2:46:21.342 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
99855ed at URL: /status)
2:46:21.342 INFO - Done: /status
2:46:26.358 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
c794cc at URL: /status)
2:46:26.358 INFO - Done: /status
2:46:31.358 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
2adf5be at URL: /status)
2:46:31.358 INFO - Done: /status
2:46:36.358 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@
b5b123b at URL: /status)
2:46:36.358 INFO - Done: /status


It is deleting sessions which I am not sure of why. Kindly help me out if anyone has any idea.

Thanks !!

Krishnan Mahadevan

unread,
May 15, 2012, 5:02:14 AM5/15/12
to webd...@googlegroups.com
How in your tests are you closing the browser ? I mean where exactly is driver.quit() getting called in your tests ?
That holds the key. If you are managing this in a common place, then we would need to know what place is that ?

How are you spawning your webdriver instances ? Is it within every @Test annotated method ? Or is it somewhere else ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.

Payal Gupta

unread,
May 15, 2012, 5:23:18 AM5/15/12
to webd...@googlegroups.com
I did a search on my code for driver.quit(). There is no such method I am invoking.

But I did found that selenium.stop() in tear down method :
    @AfterClass
    public void tearDown() throws Exception {
        if (null != selenium) {
            selenium.stop();
            // currentBrowserCount --;
        }
    }


For the second question. I have tried both approaches i.e.
spawning webdriver instances in @Test method and also before execution of @Test method

Krishnan Mahadevan

unread,
May 15, 2012, 5:31:22 AM5/15/12
to webd...@googlegroups.com
Umm.. so you are using either (WebDriverBackedSelenium or DefaultSelenium) and not WebDriver I guess.

That brings me to the next question. Is this selenium instance something which is part of every test class, or is it part of a base class from which all your test classes are being derived ?

And is this the only place wherein you are closing off selenium and nowhere else ?


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


Payal Gupta

unread,
May 15, 2012, 5:39:26 AM5/15/12
to webd...@googlegroups.com
It will be eay to explain with code:
 This is how my sample test class looks like : There are few classes with more than one methods

public class TestW7IE9{
    @Test
    public void version9() throws Exception {
        //Thread.sleep(Long.parseLong("3000"));   
        RunTestScenario scenario = new RunTestScenario();
        System.out.println("## running Internet Explorer 9 automation");
        scenario.runScenario(Global.INTERNET_EXPLORER,"9", "WINDOWS","username");
    }
    }

   
    For every test method - the below mentioned approach  is followed :
    public void runScenario(String browser , String version, String platform ,String username) {
       
        String scope = "";
        String  env = "";
       
        try {
            DSAARun run = new DSAARun();
           
            run.strBrowser = browser;
            run.strVersion  = version;
            run.strPlatform  = platform;               
            run.strUsername  = username;           
           
            env = System.getProperty("environment");           
            scope = System.getProperty("scope");
           
            System.out.println("-Denvironment -->" + env);
            System.out.println("-Dscope -->" + scope);
            System.out.println("Username -->" + username);

           
            DSAARun.environment = env;           
            DSAARun.scope = scope;
           
            run.setUp();
            run.processTestCases();
            run.tearDown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

This is how my setUp and tearDown looks like

@BeforeClass
    public void setUp() throws Exception {

        // init global element locator
        GlobalElementLocator.init();

        // boolean createdBrowser = false;
        // int timeout = 3000;
        FileInputStream fstream = new FileInputStream("Resource/system.properties");
        Properties props = new Properties();
        props.load(fstream);
        testPhase = props.getProperty("test_run_phase");

        if (strUsername == null || strUsername.isEmpty()) {
            strUsername = props.getProperty("username");
        }

        strPassword = props.getProperty("password");

        strServerUrl = props.getProperty("serverUrl");

        // get browser
        if (strBrowser.isEmpty()) {
            strBrowser = props.getProperty("browser");
        }

        //get browser version    
        if (strVersion.isEmpty()){
            strVersion = props.getProperty("version");
        }

        //get platform
        if (strPlatform.isEmpty()){
            strPlatform = props.getProperty("platform");
        }

        // get lastBuild
        strBuildNo = GlobalElementLocator.getValue("global:buildNo");

        // get environment & base url accordingly
        if (environment == null || environment.isEmpty()) {
            environment = props.getProperty("environment");
            System.out.println("environment: " + environment);
        }
       
        BASE_URL = props.getProperty(environment.toUpperCase() + "_url");

        // get scope.

        if (scope == null){
            scope = props.getProperty("scope");
        }
        if (scope.equalsIgnoreCase("full")){
            strQuery = Global.RALLY_QUERY_GET_ALL_WEB_CLIENT;
        }else if (scope.equalsIgnoreCase("smoke")){
            strQuery = Global.RALLY_QUERY_SMOKE_TEST;
        }else if (!scope.isEmpty()){
            //this query is for testing one test case in Jenkins
            strQuery = "(FormattedID%20=%20" + scope +")";
        }

        // end get scope

        Browser browser = new Browser(strBrowser, strVersion, strPlatform);
        browser.setServerUrl(strServerUrl);
        browser.setDriver();
        driver = browser.getDriver();
        System.out.println("base URL: " + BASE_URL);
        driver.get(BASE_URL);
        driver.manage().deleteAllCookies();
        selenium = new WebDriverBackedSelenium(driver, BASE_URL);
        selenium.useXpathLibrary("javascript-xpath");
        // browser behavior
        selenium.windowMaximize();
        selenium.windowFocus();
        // maximizeWindow();
        // Increase the wait time
        selenium.setTimeout("180000");

        try {
            boolean errorServer = selenium.isTextPresent("HTTP Status");
            if (errorServer == true) {
                System.out.println("this DriverUrl " + BASE_URL +" is not available");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setPlatform(String platform) {
        if (strPlatform.compareToIgnoreCase("WINDOWS") == 0) {
            strPlatform = "WINDOWS_7";
        }

        if (strPlatform.isEmpty()) {
            strPlatform = selenium.getEval("navigator.platform");

        }
    }

    @AfterClass
    public void tearDown() throws Exception {
        if (null != selenium) {
            selenium.stop();
            // currentBrowserCount --;
        }
    }

Please let me know if any more input is needed.

Krishnan Mahadevan

unread,
May 15, 2012, 6:45:37 AM5/15/12
to webd...@googlegroups.com
Payal,
I see some discrepancies here:

Even though you have annotated methods with @Test and @BeforeClass, am seeing that within your test method

you are making a call to "scenario.runScenario(Global.INTERNET_EXPLORER,"9", "WINDOWS","username");"

and within runScenario() 

you have these three calls
run.setUp();
run.processTestCases();
run.tearDown();

If your test class TestW7IE9 already has @Test, @BeforeClass and @AfterClass annotated methods, then what exactly are run.setUp(), run.processTestCases() and run.tearDown() doing ?
Are they also dealing with instantiating the Selenium instance as well ?

In my opinion, you would need to define in clear cut way, as to whether you are going to take up the responsibility of invoking setup(), teardown() or if your going to let TestNG do it for you.



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



Payal Gupta

unread,
May 16, 2012, 12:30:34 AM5/16/12
to webd...@googlegroups.com
The test class defines only the @test methods, yhey in turn calls

run.setUp();
run.processTestCases();
run.tearDown();


In my case - run.setUp() describes nothing but @BeforeClass and
run.tearDown() describes @AfterClass

As far as I understand from your comments that this setup and teardown approach is for Junit.
Is there any similar approach for TestNG also ?

Krishnan Mahadevan

unread,
May 16, 2012, 12:49:18 AM5/16/12
to webd...@googlegroups.com
Setup annotations in TestNG
@BeforeSuite - at suite level
@BeforeTest - at test level "<test> tag"
@BeforeClass - at class level
@BeforeMethod - at method level

Teardown annotations in TestNG
@AfterSuite - at suite level
@AfterTest - at test level "<test> tag"
@AfterClass - at class level
@AfterMethod - at method level


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



Payal Gupta

unread,
May 16, 2012, 12:53:46 AM5/16/12
to webd...@googlegroups.com
Thank you for your response !!
Just to clear my understanding, what exactly is cause of issue in the current implementation ?

Krishnan Mahadevan

unread,
May 16, 2012, 1:03:38 AM5/16/12
to webd...@googlegroups.com
Payal,

The cause of the issue is pretty straight forward. the sessions are getting killed somewhere. [Ofcourse you know this as well :) ]

Now there are two ways in which this can happen :

1. You opened up the browser, and left it idle long enough, for the grid to think that this session can be cleaned up and it did that. So you might want to look through in your testcases to see if between two UI operations, are you introducing a huge delay that is causing the browser to go idle ?

2. Somewhere in your code, you are invoking selenium.close() 

Take a look at this tip as well: 
http://code.google.com/p/selenium/wiki/RemoteWebDriverServer#Timeouts_(from_version_2.21) (This is applicable to the webdriver node that you are going to hook up to the grid)


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



Reply all
Reply to author
Forward
0 new messages