1
<div class="dropdown-div u-space-ls u-inline-block" data- 
reactid=".0.0.0.3.1"><a class="dropdown-div__button js-dropdown button" 
href="#" data-reactid=".0.0.0.3.1.0"><span class="u-pad-rs" data- 
reactid=".0.0.0.3.1.0.0">ACTIONS</span><span class="icon icon-caret-down" 
data-reactid=".0.0.0.3.1.0.1"></span></a><ul class="js-actions-dropdown- 
menu" data-reactid=".0.0.0.3.1.1"><li class="js-save-button" data-tooltip=" 
{&quot;placement&quot;:&quot;bottom&quot;,&quot;title&quot;:&quot;Save the 
current layout and filters as the default setting, or as a new 
report.&quot;}" data-reactid=".0.0.0.3.1.1.0"><span class="icon icon-files-o 
u-space-rs" data-reactid=".0.0.0.3.1.1.0.0"></span><span data- 
reactid=".0.0.0.3.1.1.0.1">Save Layout</span></li><li class="js-email- 
button" data-reactid=".0.0.0.3.1.1.1"><span class="icon icon-envelope-o u- 
space-rs" data-reactid=".0.0.0.3.1.1.1.0"></span><span data- 
reactid=".0.0.0.3.1.1.1.1">Email…</span></li><li data- 
reactid=".0.0.0.3.1.1.2"><span class="icon icon-file-excel-o u-space-rs" 
data-reactid=".0.0.0.3.1.1.2.0"></span><span data- 
reactid=".0.0.0.3.1.1.2.1">Export as Excel</span></li><li data- 
reactid=".0.0.0.3.1.1.3"><span class="icon icon-bar-chart u-space-rs" data- 
reactid=".0.0.0.3.1.1.3.0"></span><span data- 
reactid=".0.0.0.3.1.1.3.1">Export as CSV</span></li></ul></div>

I've tried to find the xpath and selector of "dropdown-div u-space-ls u-inline-block" and "js-actions-dropdown-menu" and clicking it but non of those options worked for me.

Starting ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb) 
on port 5073
Only local connections are allowed.
Apr 23, 2018 10:31:44 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element <div class="dropdown-div u-space-ls u-inline-block" data-reactid=".0.0.0.3.0">...</div> is not clickable at point (769, 17). Other element would receive the click: <div class="ReactModal__Overlay ReactModal__Overlay--after-open modal_container__overlay" data-reactid=".1">...</div>
  (Session info: chrome=65.0.3325.181)
  (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:08.638Z'
System info: host: 'DESKTOP-D34PQOQ', ip: '192.168.241.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.38.552522 (437e6fbedfa876..., userDataDir: C:\Users\ALVINZ~1\AppData\L...}, cssSelectorsEnabled: true, databaseEnabled: false, 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: , unhandledPromptBehavior: , version: 65.0.3325.181, webStorageEnabled: true}
Session ID: 2b96523cc89e3c10d4d8824343d438d5
    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:545)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83)
    at reader.main(reader.java:49)

This is the console after running the program.

  • It would be great if you can share more details about the html page and the WebElement you want to be clicked. Like sample web url from your or some open source website with similar element present on it. Thanks! – Akshay Apr 24 '18 at 05:11
  • I cant show the website as it contains private information but what I can say is that when you click the ACTIONS button a drop down menu appears with 4 options, I am trying the choose the 4th option("Export as CSV"). – PancakeFactory Apr 24 '18 at 05:25
  • ok, edited my answer. Your DOM should have element as "" – Akshay Apr 24 '18 at 05:31
  • Update the question with text based formatted HTML and your code trials – undetected Selenium Apr 24 '18 at 05:36
  • 1
    @Alvin_z update the question as DebanjanB said. I know what your problem is but first lets edit the question to make it readable. – Akshay Apr 24 '18 at 05:43
  • 1
    What does he mean by text based formatted HTML and code trials? – PancakeFactory Apr 24 '18 at 05:45
  • Possible duplicate of [Element MyElement is not clickable at point (x, y)... Other element would receive the click](https://stackoverflow.com/questions/44724185/element-myelement-is-not-clickable-at-point-x-y-other-element-would-receiv) – undetected Selenium Apr 24 '18 at 06:06

1 Answers1

0

This should work:

By.xpath("//div[@class='dropdown-div u-space-ls u-inline-block']"

or this:

By.xpath("//*[@class='js-actions-dropdown- menu']//*[@data-reactid='.0.0.0.3.1.1']")

or this:

By.xpath("//*[contains(@class,'dropdown-div')]")

For drop-down menu when option tags are available:

By.xpath("//option[contains(@value,'Export as CSV')]

Here xpath is one in between double quotes "". Let me know if this helped.

Akshay
  • 169
  • 1
  • 4
  • I will try this. – PancakeFactory Apr 24 '18 at 05:29
  • ;( none of them worked, here is a sample of my code: driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); driver.findElement(By.xpath("//*[contains(@class,'dropdown-div')]")).click(); – PancakeFactory Apr 24 '18 at 05:32
  • Here are the error: 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 – PancakeFactory Apr 24 '18 at 05:36
  • Basically you need two steps to get to your drop down element. And you are trying to achieve it in single step. First click the dropdown menu and then the ‘export as csv’ element option. When you are looking for dropdown options without clicking the menu, then they may not be visible and hence selenium is not able to click it. – Akshay Apr 24 '18 at 06:01
  • You can't use @data-reactid='.0.0.0.3.1.1'] in your Xpath , it'd be highly unstable . – cruisepandey Apr 24 '18 at 10:05
  • @cruisepandey it was just an example for original post, question itself was not clear as to what elements are operating on react. – Akshay Apr 24 '18 at 11:55
  • I am trying to do it in 2 steps, but 1 step is also fine what ever is easier/faster. – PancakeFactory Apr 24 '18 at 18:01