Need Help for running galen test in TestNG

403 views
Skip to first unread message

Sam

unread,
Dec 2, 2015, 7:51:38 AM12/2/15
to Galen Framework
Hi,

I am facing some issue when I run Galen tests in TestNG, I think this not a problem related to Galen but still if someone can help me.

My test is very much similar to sample java test at https://github.com/galenframework/galen-sample-java-tests , it is just that I am using Gradle instead of Maven.

When I run the test as TestNG Tests I get following error in the console:

[TestNG] Running:
  C:\Users\sam\AppData\Local\Temp\testng-eclipse--422538350\testng-customsuite.xml

C:\Windows\
com.galenframework.reports.GalenTestInfo@70aa628f
[main] ERROR com.galenframework.api.Galen - Error during setting screenshot.
java.lang.RuntimeException: Error making screenshot
at com.galenframework.browser.SeleniumBrowser.createScreenshot(SeleniumBrowser.java:92)
at com.galenframework.page.selenium.SeleniumPage.createScreenshot(SeleniumPage.java:171)
at com.galenframework.api.Galen.checkLayoutForPage(Galen.java:104)
at com.galenframework.api.Galen.checkLayout(Galen.java:90)
at com.galenframework.api.Galen.checkLayout(Galen.java:73)
at com.galenframework.api.Galen.checkLayout(Galen.java:63)
at com.galenframework.api.Galen.checkLayout(Galen.java:56)
at com.galenframework.api.Galen.checkLayout(Galen.java:145)
at com.galenframework.GalenJavaTestBase.checkLayout(GalenJavaTestBase.java:119)
at com.galenframework.GalenJavaTestBase.checkLayout(GalenJavaTestBase.java:105)
at com.xxxxxx.layout.tests.BWLayoutTestSuite.careerPage_view_onDevice(BWLayoutTestSuite.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)
Caused by: org.openqa.selenium.WebDriverException: java.io.IOException: Access is denied
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
System info: host: '.......', ip: 'xxx.xxx.xx.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_55'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.OutputType$3.save(OutputType.java:94)
at org.openqa.selenium.OutputType$3.convertFromBase64Png(OutputType.java:75)
at org.openqa.selenium.OutputType$3.convertFromBase64Png(OutputType.java:73)
at org.openqa.selenium.firefox.FirefoxDriver.getScreenshotAs(FirefoxDriver.java:343)
at com.galenframework.utils.GalenUtils.takeScreenshot(GalenUtils.java:308)
at com.galenframework.browser.SeleniumBrowser.makeSimpleScreenshot(SeleniumBrowser.java:97)
at com.galenframework.browser.SeleniumBrowser.createScreenshot(SeleniumBrowser.java:90)
... 34 more
Caused by: java.io.IOException: Access is denied
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at java.io.File.createTempFile(Unknown Source)
at java.io.File.createTempFile(Unknown Source)
at org.openqa.selenium.OutputType$3.save(OutputType.java:86)
... 40 more
FAILED CONFIGURATION: @AfterMethod quitDriver
java.lang.UnsatisfiedLinkError: Failed to create temporary file for /com/sun/jna/win32-x86-64/jnidispatch.dll library: Access is denied
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:776)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
at com.sun.jna.Native.<clinit>(Native.java:131)
at org.openqa.selenium.os.Kernel32.<clinit>(Kernel32.java:34)
at org.openqa.selenium.os.ProcessUtils.killWinProcess(ProcessUtils.java:133)
at org.openqa.selenium.os.ProcessUtils.killProcess(ProcessUtils.java:81)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.destroyHarder(UnixProcess.java:247)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.access$200(UnixProcess.java:201)
at org.openqa.selenium.os.UnixProcess.destroy(UnixProcess.java:125)
at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:155)
at org.openqa.selenium.firefox.FirefoxBinary.quit(FirefoxBinary.java:259)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.quit(NewProfileExtensionConnection.java:204)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.quit(FirefoxDriver.java:364)
at org.openqa.selenium.firefox.FirefoxDriver.stopClient(FirefoxDriver.java:310)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:519)
at com.galenframework.GalenJavaTestBase.quitDriver(GalenJavaTestBase.java:146)
at com.galenframework.testng.GalenTestNgTestBase.quitDriver(GalenTestNgTestBase.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:703)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)

PASSED: careerPage_view_onDevice(com.xxxxx.framework.galencomponents.GalenTestBase$TestDevice@482ee649)

===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 0
    Configuration Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.EmailableReporter2@2ac28d29: 51 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 1 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@3bf4899c: 21 ms
[main] INFO com.galenframework.testng.GalenTestNgReportsListener - Generating Galen Html reports
[TestNG] Time taken by com.galenframework.testng.GalenTestNgReportsListener@5601cb79: 1216 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@2ddf191: 19 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@41f8f72f: 129 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@361e3f69: 95 ms


I am not sure why it wants to write temp file at C:\Windows\ folder.

Earlier I was facing problem in launching firefox itself for which I was getting following exception

org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055; process output follows: 
null
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
System info: host: 'xxxxxxxxxx', ip: 'xxx.xxx.xx.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_55'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:139)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:117)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at com.xxxxxx.framework.galencomponents.GalenTestBase.createDriver(GalenTestBase.java:19)
at com.galenframework.GalenJavaTestBase.initDriver(GalenJavaTestBase.java:133)
at com.galenframework.testng.GalenTestNgTestBase.initDriver(GalenTestNgTestBase.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:585)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176)
Caused by: org.openqa.selenium.WebDriverException: Unable to create temporary file at C:\Windows
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
System info: host: 'xxxxxxxxxx', ip: 'xxx.xxx.xx.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_55'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.io.TemporaryFilesystem.createTempDir(TemporaryFilesystem.java:99)
at org.openqa.selenium.firefox.FirefoxProfile.layoutOnDisk(FirefoxProfile.java:417)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:95)
... 35 more

Which also wants to create temp file at C:\Windows folder. I was able to overcome this problem just by adding a simple line of code that will force it to change the temp file directory.

TemporaryFilesystem.setTemporaryDirectory(new File("C:/TEMP"));

So the modified section of GalenTestBase.java looks similar to following:

 @Override
    public WebDriver createDriver(Object[] args) {
    TemporaryFilesystem.setTemporaryDirectory(new File("C:/TEMP"));
              WebDriver driver = new FirefoxDriver();
   
        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());
                }
            }
        }
        return driver;
    }

I think this is not a problem with Galen. Kindly help me with this. 

Please let me know if you need more information on this regard

Regards,
Sam


Martin Reinhardt

unread,
Dec 2, 2015, 9:17:37 AM12/2/15
to Galen Framework
seems you didn't have enought user rights for running automated tests. Under windows you need to run it as admin

Sam

unread,
Dec 3, 2015, 8:41:07 AM12/3/15
to Galen Framework
I was able to manage the above situation by changing the value of system property java.io.tmpdir to a new accessible location.

again replaced following 
TemporaryFilesystem.setTemporaryDirectory(new File("C:/TEMP"));

with 
System.setProperty("java.io.tmpdir", "C:/TEMP");

Also, added a check before this 
                    if(!new File("C:/TEMP").isDirectory())
try {
FileUtils.forceMkdir(new File("C:/TEMP"));
} catch (IOException e) {
e.printStackTrace();
}

After this I encountered another exception and it was with driver.quit(); and following was the exception

java.lang.RuntimeException: Process refused to die after 10 seconds, and couldn't taskkill it: Unable to find executable for: taskkill
at org.openqa.selenium.os.ProcessUtils.killWinProcess(ProcessUtils.java:143)
at org.openqa.selenium.os.ProcessUtils.killProcess(ProcessUtils.java:81)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.destroyHarder(UnixProcess.java:247)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.access$200(UnixProcess.java:201)
at org.openqa.selenium.os.UnixProcess.destroy(UnixProcess.java:125)
at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:155)
at org.openqa.selenium.firefox.FirefoxBinary.quit(FirefoxBinary.java:259)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.quit(NewProfileExtensionConnection.java:204)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.quit(FirefoxDriver.java:364)
at org.openqa.selenium.firefox.FirefoxDriver.stopClient(FirefoxDriver.java:310)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:519)
at com.bitwise.framework.galencomponents.GalenTestNgTestBase2.quitDriver(GalenTestNgTestBase2.java:60)
Caused by: java.lang.NullPointerException: Unable to find executable for: taskkill
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:250)
at org.openqa.selenium.os.UnixProcess.<init>(UnixProcess.java:62)
at org.openqa.selenium.os.CommandLine.<init>(CommandLine.java:38)
at org.openqa.selenium.os.WindowsUtils.killPID(WindowsUtils.java:178)
at org.openqa.selenium.os.ProcessUtils.killWinProcess(ProcessUtils.java:138)
... 37 more


After searching I found this problem occurs when taskkill.exe is not accessible, this executable is located at C:\Windows\System32 and  the same location should be part of your system environment variable PATH 

In my case again it was already in the PATH variable, it was very weird that eclipse was not able to access any system variable ie the output of following was null 

String path = System.getenv("PATH");
System.out.println(path);

Here I found the way to add system variable in eclipse itself. And again very weird, just to try I added a variable as "test" and its value as "test" and the eclipse was able to access all the system path variable later like M2, JAVA_HOME and the most needed "PATH".

I understand this is very unexpected thing but just sharing the experience so that if any one else is facing the same issue this may help them.

Yeh ... I know this sounds very weird.

Regards,
Sam
Reply all
Reply to author
Forward
0 new messages