Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

No such element - exception Selenium

 
Ranch Hand
Posts: 459
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

The same test case works well sometimes, sometimes fails.

This is the error message :

No such element (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 15.29 seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58' System info: host: '185-129-71-57', ip: '185.129.71.57', os.name: 'windows', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_121' Driver info: org.openqa.selenium.edge.EdgeDriver Capabilities [{applicationCacheEnabled=true, acceptSslCerts=true, browserVersion=38.14393.0.0, platformVersion=10, locationContextEnabled=true, webStorageEnabled=true, browserName=MicrosoftEdge, takesScreenshot=true, pageLoadStrategy=normal, takesElementScreenshot=true, platformName=windows, platform=ANY}] Session ID: 5C94189C-E152-4957-9AE9-0F0431A7A3A9 *** Element info: {Using=xpath, value=//input[@id='login-signin']}

See attached my test case successful.

The video file for failed test case is too big.

What is the reason?



 
Bartender
Posts: 322
24
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dana,

As the exception name would indicate, NoSuchElementException, usually means that the element wasn't present on the page when Selenium attempted to find it.
(Link here to the  org.openqa.selenium.NoSuchElementException API as the link above will go to  java.util.NoSuchElementException ).

Two common reasons:
  • It's a totally valid error. Someone changed the page and either deleted the element or accidentally changed the id. If that was the case, you would want to know.  
  • Selenium tried processing the page before the page was fully loaded.

  • In your case, since the test sometimes pass, I would think it's the second reason.

    Are you using a WebDriverWait statement to make sure the element has loaded before Selenium attempts to access?

    While you could use that to reference the specific id in question, a better approach is to put at the very bottom of the page (usually through a shared footer or something just before the </body>) a placeholder id for WebDriverWait to hook into:
    <div id="wait_holder"></div>

    Cheers!
     
    Dana Ucaed
    Ranch Hand
    Posts: 459
    6
    Netbeans IDE Oracle Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I modified the catch block:




    and the real cause is below:


    So, is ignored sendkeys for password, but Selenium search *** Element info: {Using=id, value=yui_3_10_3_1_1375219693637_127} on page where I write the password.

    I am very disappointed because I don't understand this behaviour.

    My test stays on the page where I can introduce my password, but search   the element info: {Using=id, value=yui_3_10_3_1_1375219693637_127} that exists on the nest web page.

    I will ask Microsoft Edge team about this situation.





     
    Dana Ucaed
    Ranch Hand
    Posts: 459
    6
    Netbeans IDE Oracle Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    If in my catch block write




    java.lang.NullPointerException
    at LoginYahooSuccess.test(LoginYahooSuccess.java:95)
    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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


      Bookmark Topic Watch Topic
    • New Topic