2

I have this problem that when I run in root account it works properly with the test cases returning as expected. But in a non-root account it keeps giving me an error. Thanks in advance if you are helping me out.

What I have done:

  • Use selenium IDE to export into test case in JUnit Webdriver
  • Mavenized and execute the test.
  • This server is Ubuntu 12.04

Maven file is as below:

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.ncs</groupId>
  <artifactId>selenium-test</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>2.35.0</version>
    </dependency>
  </dependencies>

  <build>
    <finalName>IntegrationTest</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.1</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

The error is as below:

-------------------------------------------------------------------------------
Test set: TestGoogle
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 33.153 sec <<< FAILURE!
testGoogle(TestGoogle)  Time elapsed: 33.137 sec  <<< ERROR!
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"link text","selector":"Gmail"}
Command duration or timeout: 30.03 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.35.0', revision: '8df0c6bedf70ff9f22c647788f9fe9c8d22210e2', time: '2013-08-17 12:46:41'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.2.0-51-generic-pae', java.version: '1.6.0_33'
Session ID: 524ff8d4-1ea3-4421-b9c1-ae1c34d8fd66
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=25.0, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:191)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByLinkText(RemoteWebDriver.java:356)
    at org.openqa.selenium.By$ByLinkText.findElement(By.java:241)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
    at TestGoogle.testGoogle(TestGoogle.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
    at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
    at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to locate element: {"method":"link text","selector":"Gmail"}
Build info: version: '2.35.0', revision: '8df0c6bedf70ff9f22c647788f9fe9c8d22210e2', time: '2013-08-17 12:46:41'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.2.0-51-generic-pae', java.version: '1.6.0_33'
Driver info: driver.version: unknown
    at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///tmp/anonymous5771616614386270554webdriver-profile/extensions/[email protected]/components/driver_component.js:8880)
    at <anonymous class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///tmp/anonymous5771616614386270554webdriver-profile/extensions/[email protected]/components/driver_component.js:396)
6
  • Does the browser start up? If so, does the test successfully send the browser to any pages?
    – user246
    Commented Nov 13, 2013 at 13:18
  • Its within the xvfb so its not shown. But according to when its ran on the root account, everything was successful.
    – Cheng
    Commented Nov 13, 2013 at 14:33
  • since there is exception about "NoSuchElementException" should not it mean that browser was indeed launched?
    – Tarun
    Commented Nov 14, 2013 at 15:58
  • please add the generated code as well.
    – Buddha
    Commented Feb 2, 2014 at 9:59
  • 1
    To work out why you get a NoSuchElementException, you need to know the state of the browser on the line which is erroring. I recommend you set up a junit rule which will make it take a screenshot (if that is possible) and log the state of the DOM. That way, you'll be able to diagnose these errors yourself; and that's an important skill, because if you work with webdriver much you will get a lot of those errors. Commented Apr 25, 2015 at 21:51

1 Answer 1

-3

It appears that you would benefit by using Selenium Builder instead of Selenium IDE. To me, from my experience, it appears from your stack trace that your issue with Selenium IDE might be having a version compatability issue with the newest Firefox 35. I use Selenium Builder all the time and I don't have issues with it.

Another way you might solve this is by upgrading to Selenium 2.42.2 or higher and see if the browser issue resolves itself. The problem with staying on an older version of Selenium (2.35 in your case) is that you never know when a newer browser update might cause a quirk.

1
  • Could you please justify why and elaborate how Selenium Builder would solve the OP's problem?
    – dzieciou
    Commented Jun 28, 2014 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.