Forum Discussion

Codartizan's avatar
Codartizan
Occasional Contributor
8 years ago
Solved

After running a SoapUI, could not start selenium

I got a problem. I run a SoapUI web service test through my Java automation code. But After that. Selenium doesn't work. It seems soapUI part not actually done. But I'm not sure.

 

        public static void main(String[] args) throws Exception {
            SoapUIRun srun = new SoapUIRun();
            srun.runTestCase("CPIHS", "CPIHS");
            new MainPage().LoginCad();
        }


The exception msg is :

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'GFG-GROUP153', ip: '10.100.1.7', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at screens.MainPage.LoginCad(MainPage.java:28)
at screens.MainPage.main(MainPage.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)


Caused by: java.lang.NullPointerException
at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:79)
at org.apache.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:77)
at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:124)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:183)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:144)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:90)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 13 more


However is I comment out SoapUI part. It will work again. Like:

        public static void main(String[] args) throws Exception {
            //SoapUIRun srun = new SoapUIRun();
            //srun.runTestCase("CPIHS", "CPIHS");
            new MainPage().LoginCad();
        }

 

Here is my SoapUI method:

 

        public void runTestCase(String tarSuite, String tarCase) throws Exception {

            String reportStr = "";

            TestRunner runner;

            SoapUI.setSoapUICore(new StandaloneSoapUICore(true));

            WsdlProject project = new WsdlProject("C:\\Users\\tshi\\Documents\\Maven                         Projects\\ASORT\\WebServiceResource\\Suncorp_Issuing-soapui-project.xml");

            List<TestSuite> suiteList = project.getTestSuiteList();

            for (TestSuite aSuiteList : suiteList) {

                String suiteName = aSuiteList.getName();

                List<TestCase> caseList = aSuiteList.getTestCaseList();
                //System.out.println("Test Suite: " + suiteName);

                if (suiteName.equals(tarSuite)) {

                    for (TestCase aCaseList : caseList) {

                    String caseName = aCaseList.getName();
                    //System.out.println("Test Case: " + caseName);

                        if (caseName.equals(tarCase)) {

                            long startTime = System.currentTimeMillis();

                            runner = project.getTestSuiteByName(suiteName).getTestCaseByName(caseName).run(new                   PropertiesMap(), false);

                            long duration = System.currentTimeMillis() - startTime;

                            reportStr = reportStr + "\n\tTestCase: " + aCaseList.getName() + "\tStatus: " + runner.getStatus() + "\tReason: " + runner.getReason() + "\tDuration: " + duration;

                            System.out.print(reportStr);

                            }

                        }

                    }

                }

        }


Here is Selenium related method:

 

    public void LoginCad(){
        System.setProperty("webdriver.chrome.bin", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
        System.setProperty("webdriver.chrome.driver","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");

        String bank = Integer.toString(48);
        String emp = Integer.toString(200003);
        String pwd = "Cadencie1";
        String baseUrl = "http://172.16.1.133:8090/AppName/servlet/app";

        driver = new ChromeDriver();

        driver.get(baseUrl);

        try {

            Thread.sleep(1000);

             } catch(InterruptedException e){

             // TO DO Auto-generated catch block
             e.printStackTrace();

             }

        Utilities.switchToWindow("AppName - User Logon [LOGON]", driver);

        try{

            Thread.sleep(2000);

            } catch(InterruptedException e){

            // TO DO Auto-generated catch block
           e.printStackTrace();

           }

        driver.findElement(By.id("idBANK")).clear();
        driver.findElement(By.id("idBANK")).sendKeys(bank);

        driver.findElement(By.id("idEMPLOYEE")).clear();
        driver.findElement(By.id("idEMPLOYEE")).sendKeys(emp);

        driver.findElement(By.id("idPASSWORD")).clear();
        driver.findElement(By.id("idPASSWORD")).sendKeys(pwd);

        driver.findElement(By.id("maintLOGON")).click();

        driver.findElement(By.id("idPASSWORD")).clear();
        driver.findElement(By.id("idPASSWORD")).sendKeys(pwd);

        driver.findElement(By.id("maint")).click();

        }


Anyone has any idea why this happen. I searched on google. But it seems nobody gets same error in the same situation. Thank you very much.

5 Replies