Module 20 Release 2016 - GMAIL Log in | Selenium Forum
M
Posted on 21/07/2016
Hello I am getting a strange error. I dont know how to tackle it . Please help me.
Every steps in code work fine but when it comes to click. it throws error. I am 110% that my xpath is correct.
-----------------------------------------------------------------------------------------------------------
DummyTest B.java
---------------------------------------------------------------------------------------------
package com.qtpselenium.core.ddf.testcases;
import org.testng.annotations.Test;
import com.qtpselenium.core.ddf.base.TestBase;
public class DummyTestB extends TestBase {

@Test
public void testB(){

openBrowser("Mozilla");
navigate("appurl"); //Gmail url
type("email_xpath","itengineer3108@gmail.com"); //type email and pass data
click("button_xpath"); //here is the trouble (Used xpath = //*[@id='next'])
}
}
-----------------------------------------------------------------------------------------------
ERROR
----------------------------------------------------------------------------------------------
[TestNG] Running:
C:\Users\Admin\AppData\Local\Temp\testng-eclipse--1988948475\testng-customsuite.xml

log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
FAILED: testB
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"button_xpath"}
Command duration or timeout: 20.14 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'Admin-PC', ip: '192.168.43.44', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_80'
*** Element info: {Using=xpath, value=button_xpath}
Session ID: a0105545-d844-4d52-b811-62b92e829338
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=46.0.1}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:500)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)
at com.qtpselenium.core.ddf.base.TestBase.click(TestBase.java:47)
at com.qtpselenium.core.ddf.testcases.DummyTestB.testB(DummyTestB.java:15)
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:606)
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:821)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:773)
at org.testng.TestRunner.run(TestRunner.java:623)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1018)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"button_xpath"}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'Admin-PC', ip: '192.168.43.44', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_80'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/Admin/AppData/Local/Temp/anonymous8078216827583615642webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10723)
at <anonymous class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///C:/Users/Admin/AppData/Local/Temp/anonymous8078216827583615642webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:623)


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


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

[TestNG] Time taken by org.testng.reporters.EmailableReporter2@4b935405: 10 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@147eef21: 19 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@6c7e6b26: 58 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@4103bc02: 47 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 18 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@782be20e: 11 ms

M
Replied on 21/07/2016

My click function in TestBase class
------------------------------------------
public void click(String xpathEleKey){
driver.findElement(By.xpath(xpathEleKey)).click();


M
Replied on 21/07/2016

I am sorry This is solved