RE: First Test Case with Selenium error

First Test Case with Selenium
http://www.toolsqa.com/selenium-webdriver/first-test-case/

error:

Exception in thread “main” org.openqa.selenium.NoSuchElementException: Unable to locate element: {“method”:”xpath”,”selector”:”.//*[@id=’account_logout’]/a”}
Command duration or timeout: 10.02 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘2.43.0’, revision: ‘597b76b’, time: ‘2014-09-09 20:52:38’
System info: host: ‘Selenium’, ip: ‘192.168.117.64’, os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.7.0_67′
Session ID: af9469d3-1db5-4b32-a2a6-9b722c587532
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, webStorageEnabled=true, nativeEvents=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=32.0.1}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:449)
at org.openqa.selenium.By$ByXPath.findElement(By.java:357)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at automationFramework.FirstTestCase.main(FirstTestCase.java:53)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {“method”:”xpath”,”selector”:”.//*[@id=’account_logout’]/a”}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘2.43.0’, revision: ‘597b76b’, time: ‘2014-09-09 20:52:38’
System info: host: ‘Selenium’, ip: ‘192.168.117.64’, os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.7.0_67’
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/pc/AppData/Local/Temp/anonymous1450587665133173591webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:9618:133)
at <anonymous class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///C:/Users/pc/AppData/Local/Temp/anonymous1450587665133173591webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:548:5)

ohwweee Default Asked on September 16, 2014 in Selenium WebDriver.
Add Comment
7 Answers

You can try this

Thread.sleep(1000);
drive.findElement(By.xpath(“/html/body/div[2]/div/div/header/div[1]/a”)).click()

May be this may work

Doctor Answered on September 16, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.