Unable to click the link | Selenium Forum
K
Krishna Kishore Posted on 12/12/2018
Hello Team,

In my application i am not able to click the link shown in the screenshot , i tried with different combinations of xpaths using the keyworkds contains, starts-with and tried with different waits like explicit, fluentwait and still i am not able to click the link always it is giving "no such elementexception". These are the xpath i am trying to use and click  driver.findElement(By.xpath("//div[starts-with(@id,'live_search_cat_table_head_54_8')]/strong/a")).click(); and By.xpath("//div[starts-with(@id,'services_live_search_si_results_54_cat')]/div/strong/a"))) .

None of the combinations are working . Please guide me what to do .

A
Ashish Thakur Replied on 12/12/2018

Does it give error
OR
It moves ahead and click simulation is not done


K
Krishna Kishore Replied on 12/12/2018

I am getting this error apart from wait tried with Actions class as well . Nothing is working 

Starting ChromeDriver 2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90) on port 6221
Only local connections are allowed.
Dec 12, 2018 1:00:59 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
CDwindow-2E0722BBF4C19345A03A90C015FACBED
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[starts-with(@id,'live_search_cat_table_head_54_8')]/strong/a"}
(Session info: chrome=70.0.3538.110)
(Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: '5CG63862YD', ip: '192.168.0.152', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.44.609538 (b655c5a60b0b54..., userDataDir: C:\Users\kishore1\AppData\L...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:54759}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 70.0.3538.110, webStorageEnabled: true}
Session ID: 46b787fdcaa5a7f0d772780eb48eb56c
*** Element info: {Using=xpath, value=//div[starts-with(@id,'live_search_cat_table_head_54_8')]/strong/a}
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:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at Create_Request.main(Create_Request.java:121)


K
Krishna Kishore Replied on 12/12/2018

simulation is also not happening


A
Ashish Thakur Replied on 14/12/2018

Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element

This error means  that  its  not  able  to  find  the  element


Try to give some wait before finding the element
Also check in chrome inspector if xpath is coming on that element by pasting xpath in chrome inspector