galen icon indicating copy to clipboard operation
galen copied to clipboard

Galen on Jenkins not working

Open axelbarfod1 opened this issue 7 years ago • 8 comments

Hi I'm having the following issue when running galen on Jenkins (see error below). Locally the tests works but when it runs fine. Is there an extra configuration on Jenkins for Galen ?

INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
Starting ChromeDriver 2.34.522913 (36222509aa6e819815938cbf2709b4849735537c) on port 17200
Only local connections are allowed.
org.mozilla.javascript.WrappedException: Wrapped org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.4.0-1022-aws x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.07 seconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'b493035af60e', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-1022-aws', java.version: '1.8.0_151'
Driver info: driver.version: ChromeDriver (<cmd>#37)
	at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1754)
	at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:148)
	at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
	at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
	at org.mozilla.javascript.gen._cmd__18._c_createDriver_2(<cmd>:37)
	at org.mozilla.javascript.gen._cmd__18.call(<cmd>)
	at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
	at org.mozilla.javascript.gen._app___test_test_e2e_ui_galen_tests_______ui_galen_config_devices_js_25._c_anonymous_13(/app/./test/test-e2e/ui_galen/tests/../../ui_galen/config/devices.js:78)
	at org.mozilla.javascript.gen._app___test_test_e2e_ui_galen_tests_______ui_galen_config_devices_js_25.call(/app/./test/test-e2e/ui_galen/tests/../../ui_galen/config/devices.js)
	at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
	at org.mozilla.javascript.gen._app___test_test_e2e_ui_galen_tests_______ui_galen_config_galen_config_js_23._c_openDriverForDevice_6(/app/./test/test-e2e/ui_galen/tests/../../ui_galen/config/galen_config.js:58)
	at org.mozilla.javascript.gen._app___test_test_e2e_ui_galen_tests_______ui_galen_config_galen_config_js_23.call(/app/./test/test-e2e/ui_galen/tests/../../ui_galen/config/galen_config.js)
	at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
	at org.mozilla.javascript.gen._app___test_test_e2e_ui_galen_tests_______ui_galen_config_galen_config_js_23._c_anonymous_9(/app/./test/test-e2e/ui_galen/tests/../../ui_galen/config/galen_config.js:83)
	at org.mozilla.javascript.gen._app___test_test_e2e_ui_galen_tests_______ui_galen_config_galen_config_js_23.call(/app/./test/test-e2e/ui_galen/tests/../../ui_galen/config/galen_config.js)
	at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2429)
	at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:269)
	at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:97)
	at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)
	at org.mozilla.javascript.gen._cmd__17._c_invokeFunc_2(<cmd>:33)
	at org.mozilla.javascript.gen._cmd__17.call(<cmd>)
	at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
	at org.mozilla.javascript.gen._cmd__17._c_anonymous_22(<cmd>:280)
	at org.mozilla.javascript.gen._cmd__17.call(<cmd>)
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3090)
	at org.mozilla.javascript.gen._cmd__17.call(<cmd>)
	at org.mozilla.javascript.JavaAdapter.doCall(JavaAdapter.java:606)
	at org.mozilla.javascript.JavaAdapter.access$000(JavaAdapter.java:15)
	at org.mozilla.javascript.JavaAdapter$1.run(JavaAdapter.java:586)
	at org.mozilla.javascript.Context.call(Context.java:489)
	at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:504)
	at org.mozilla.javascript.JavaAdapter.callMethod(JavaAdapter.java:583)
	at adapter3.execute(<adapter>)
	at com.galenframework.TestRunnable.runTest(TestRunnable.java:75)
	at com.galenframework.TestRunnable.run(TestRunnable.java:101)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally

axelbarfod1 avatar Jan 19 '18 14:01 axelbarfod1

on a server you'll either needs an Xserver (like Xvfb) installed or set headless execution for chrome to run graphical tests

hypery2k avatar Jan 19 '18 14:01 hypery2k

how could I set headless on the chromedriver instance ?

axelbarfod1 avatar Jan 19 '18 15:01 axelbarfod1

you may add headless to your chrome options. The python equivalent is options.add_argument('headless')

biswajit-713 avatar Jan 23 '18 22:01 biswajit-713

@biswajit-713 How to set headless for chrome when I'm using Galen JavaScript API

t2hv33 avatar Jan 24 '18 06:01 t2hv33

Yeah, I don't know how to start chrome using headless using the JS API is there a property on galen.config?

axelbarfod1 avatar Jan 24 '18 13:01 axelbarfod1

@hypery2k I have already installed xvfb. I use it to run my selenium tests and they run fine but for some reason which I can't understand is that galen isn't working on jenkins and local it does.

axelbarfod1 avatar Jan 24 '18 14:01 axelbarfod1

@axelbarfod1 I don't know you're concrete setup. But here is an example from this repo. Just create a job like this: galen_sample_javascript_config__jenkins_

hypery2k avatar Feb 15 '18 18:02 hypery2k

Hello @axelbarfod1 ,

This is only for JAVA users of Galen !

I have overriden some of the methods to use my own configurations.

Check this part in my code -

       try {
            driver = getDriver();
        } catch (RuntimeException e) {
            LOGGER.info(e + " , Hence instantiating new " + browser + " instance.");
        }

Full code here -

//public class MyGalenConfig extends GalenTestNgTestBase { //In this class

    @Override
    public WebDriver createDriver(Object[] args) {
        WebDriver driver = null;
        String browser = findBrowserName(args[0]);
        try {
            driver = getDriver(browser);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (args.length > 0) {
            if (args[0] != null && args[0] instanceof TestDevice) {
                TestDevice device = (TestDevice)args[0];
                if (device.getScreenSize() != null) {
                    driver.manage().window().setSize(device.getScreenSize());
                }
            }
        }
        LOGGER.info("\n\n+++++++++++++++ - Instance Divider - +++++++++++++++++++\n");
        LOGGER.info("Browser Driver : " + driver);
        return driver;
    }

    private String findBrowserName(Object arg) {
        String browser = ((UserData) arg).getBrowser();
        if(StringUtils.isEmpty(browser)){
            browser = "firefox"; //I used to get this from config file
        }
        return browser;
    }

    @Override
    public WebDriver getDriver(String browser) throws FileNotFoundException {
        WebDriver driver = null;
		
		/** Use the driver if already there is one **/
       try {
            driver = getDriver();
        } catch (RuntimeException e) {
            LOGGER.info(e + " , Hence instantiating new " + browser + " instance.");
        }


        if(driver == null){
            if(browser.equals(FIREFOX)) {
                setDriverPathInSystemProperty("webdriver.firefox.bin","firefox"));
                driver = new FirefoxDriver();
                driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

            }else if (browser.equals(CHROME)) {
                setDriverPathInSystemProperty("webdriver.chrome.driver", "chrome"));
                driver = new ChromeDriver();
                driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
            }else if (browser.equals(INTERNET_EXPLORER)){
                setDriverPathInSystemProperty("webdriver.ie.driver", "internetExplorer");
                driver = new InternetExplorerDriver();
                driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
            }
        }
        return driver;
    }

Let me know if this doesn't work for you .

pingdpk avatar Jun 12 '18 05:06 pingdpk