86071

Mono “Hello World” example working, but Java is not

Question:

I'm running the <a href="https://saucelabs.com/home" rel="nofollow">Getting Started Examples</a> from the Sauce Labs homepage both with Java and C# Mono.

The Mono example works like a charm, but the Java one reports that

Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

I've tried re-writing the Java example to be similar to the Mono example as such:

public class WebDriverTest { private WebDriver driver; @Before public void setUp() throws Exception { DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("version", "10"); capabilities.setCapability("platform", Platform.LINUX); capabilities.setCapability("name", "Testing Selenium 2 with C# on Sauce"); capabilities.setCapability("username", "banksysan"); capabilities.setCapability("accessKey", "MY-APP-KEY"); driver = new RemoteWebDriver( new URL("http://ondemand.saucelabs.com:80/wd/hub"), capabilities); } @Test public void webDriver() throws Exception { driver.get("http://www.amazon.com/"); assertEquals("Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more", driver.getTitle()); } @After public void tearDown() throws Exception { driver.quit(); } }

Any other suggestions?

Thanks

<strong>Update</strong>

I've tried running as described in the <a href="https://saucelabs.com/java" rel="nofollow">tutorial</a> as suggested by Ross below, following this verbatum causes Maven to exit with the following error:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project sauce-labs-tutorial: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? -> [Help 1]

I have edited the sauce files, just adding the package declaration which is missing, however adding this didn't make any difference at all.

<strong>UPDATE 2</strong>

Complete Maven stack trace:

------------------------------------------------------- T E S T S ------------------------------------------------------- Forking command line: /bin/sh -c cd /home/david/Documents/development/sauceLabs/java/sauce-labs-tutorial && /usr/java/jdk1.7.0_11/jre/bin/java -jar /home/david/Documents/development/sauceLabs/java/sauce-labs-tutorial/target/surefire/surefirebooter5443687714708881867.jar /home/david/Documents/development/sauceLabs/java/sauce-labs-tutorial/target/surefire/surefire4108475136019888668tmp /home/david/Documents/development/sauceLabs/java/sauce-labs-tutorial/target/surefire/surefire_08561306448128018862tmp Running TestSuite Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3:16.389s [INFO] Finished at: Wed Mar 13 20:17:58 GMT 2013 [INFO] Final Memory: 10M/213M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project sauce-labs-tutorial: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test failed: There was an error in the forked process [ERROR] java.lang.NullPointerException [ERROR] at dave.WebDriverWithHelperTest.getSessionId(WebDriverWithHelperTest.java:78) [ERROR] at com.saucelabs.testng.SauceOnDemandTestListener.markJobAsFailed(SauceOnDemandTestListener.java:103) [ERROR] at com.saucelabs.testng.SauceOnDemandTestListener.onTestFailure(SauceOnDemandTestListener.java:97) [ERROR] at org.testng.internal.Invoker.runTestListeners(Invoker.java:1895) [ERROR] at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879) [ERROR] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1292) [ERROR] at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) [ERROR] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) [ERROR] at org.testng.TestRunner.privateRun(TestRunner.java:767) [ERROR] at org.testng.TestRunner.run(TestRunner.java:617) [ERROR] at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) [ERROR] at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) [ERROR] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) [ERROR] at org.testng.SuiteRunner.run(SuiteRunner.java:240) [ERROR] at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) [ERROR] at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) [ERROR] at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) [ERROR] at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) [ERROR] at org.testng.TestNG.run(TestNG.java:1031) [ERROR] at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77) [ERROR] at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:189) [ERROR] at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:105) [ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:117) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.lang.reflect.Method.invoke(Method.java:601) [ERROR] at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208) [ERROR] at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158) [ERROR] at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86) [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95) [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project sauce-labs-tutorial: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test failed: There was an error in the forked process java.lang.NullPointerException at dave.WebDriverWithHelperTest.getSessionId(WebDriverWithHelperTest.java:78) at com.saucelabs.testng.SauceOnDemandTestListener.markJobAsFailed(SauceOnDemandTestListener.java:103) at com.saucelabs.testng.SauceOnDemandTestListener.onTestFailure(SauceOnDemandTestListener.java:97) at org.testng.internal.Invoker.runTestListeners(Invoker.java:1895) at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1292) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at org.testng.TestNG.run(TestNG.java:1031) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:189) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:105) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test failed: There was an error in the forked process java.lang.NullPointerException at dave.WebDriverWithHelperTest.getSessionId(WebDriverWithHelperTest.java:78) at com.saucelabs.testng.SauceOnDemandTestListener.markJobAsFailed(SauceOnDemandTestListener.java:103) at com.saucelabs.testng.SauceOnDemandTestListener.onTestFailure(SauceOnDemandTestListener.java:97) at org.testng.internal.Invoker.runTestListeners(Invoker.java:1895) at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1292) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at org.testng.TestNG.run(TestNG.java:1031) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:189) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:105) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: java.lang.RuntimeException: There was an error in the forked process java.lang.NullPointerException at dave.WebDriverWithHelperTest.getSessionId(WebDriverWithHelperTest.java:78) at com.saucelabs.testng.SauceOnDemandTestListener.markJobAsFailed(SauceOnDemandTestListener.java:103) at com.saucelabs.testng.SauceOnDemandTestListener.onTestFailure(SauceOnDemandTestListener.java:97) at org.testng.internal.Invoker.runTestListeners(Invoker.java:1895) at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1292) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at org.testng.TestNG.run(TestNG.java:1031) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:189) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:105) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:475) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:349) at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:152) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:806) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:701) at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:629) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) ... 20 more [ERROR] [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Browsong the WWW it looks like surefire has been spotted as a possible culprit. I've upgraded the version in the POM but the problem still persists.

Answer1:

Can you try create the RemoteWebDriver instance using the following code:

driver = new RemoteWebDriver( new URL("http://banksysan:MY-APP-KEY@ondemand.saucelabs.com:80/wd/hub"), capabilities);

We've also created a <a href="http://saucelabs.com/java" rel="nofollow">more in-depth tutorial</a> on getting Java tests to work with Sauce Labs, which might help too.

<hr />

Update: The underlying error that was generated was

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.31.0', revision: '1bd294d185a80fa4206dfeab80ba773c04ac33c0', time: '2013-02-27 13:51:26' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.5.0-25-generic', java.version: '1.7.0_11' Driver info: driver.version: RemoteWebDriver

which in turn was due to a proxy server that was blocking the outbound request to ondemand.saucelabs.com.

Including the proxy information by specifying Java system properties resolved the issue, eg.

System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", proxyPort) System.setProperty("http.proxyUser", userName); System.setProperty("http.proxyPassword", password);

Recommend

  • How come forked processes do not affect each other when there is a global pointer?
  • Reading only the words of a specific speaker and adding those words to a list
  • Rvest: getting node text and not its childen's text
  • How is inheritance implemented in Ada and does it have built in GUI?
  • How to upload file to S3 from GAE (a horror story)
  • Can I do more have javascript do two things at once?
  • wchar_t is 2-bytes in visual studio and stores UTF-16. How do Unicode-aware applications work with c
  • Web Application and In-Memory State
  • Using replacements with a raw Sequelize query: avoiding single quotes?
  • Determine if UTF-8 encoded NSData contains a null-terminated string
  • How to convert one data type to another
  • How to send None with Signals across threads?
  • Associate git repo with existing fork network
  • Can you pass data to a test fixture just like you pass data to test cases?
  • Getting zero results in search using elastic4s
  • RPMs for IDAS IoTAgents GE, from Fiware
  • What is the likely cause of a net::ERR_CONNECTION_ABORTED when uploading a file to Spring
  • CRASH: *** -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds [0 .. 9]
  • Lua: Line breaks in strings
  • What Makes These Two Array Adds Different?
  • Is there a way to save the selected text and highlight it again once the page is refreshed?
  • Redshift Querying: error xx000 disk full redshift
  • NUnit 3.0 TestCase const custom object arguments
  • Bash if statement with multiple conditions
  • How to remove a SwiftyJSON element?
  • Problems installing Yesod for Haskell
  • Unable to install Git-core+svn by MacPorts
  • Is there a way to do normal logging with EureakLog?
  • Swift: Switch statement fallthrough behavior
  • VSO Build — Response status code does not indicate success: 404 (Not Found)
  • D3 nodes and links from JSON with nested arrays of children
  • ilmerge with a PFX file
  • Pass value from viewmodel to script in zk
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • How to format a variable of double type
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • Error creating VM instance in Google Compute Engine
  • How does Linux kernel interrupt the application?
  • How to Embed XSL into XML