0

enter image description here

I am trying to access the div node via

//div[@data-full='2018-1-15']

Normally I would just search by Xpath and grab this node. However the nature of the site is that there are a number of nodes with this property, and only one is clickable.

Because of this I have to grab the

//div[@class='dw-cal-slide dw-cal-slide-a'] 

node first and then step down. I know I'm trying to do something like this:

Step down one node:

//div[@class='dw-cal-slide dw-cal-slide-a']/div/

And then search for child nodes that have a child node of their own with the property

//div[@data-full='2018-1-15']. 

Having trouble with the syntax. Any help would be great!

Andersson
  • 51,635
  • 17
  • 77
  • 129
Daniel Schissler
  • 115
  • 1
  • 1
  • 5
  • Welcome to Stack Overflow! Please read why [a screenshot of code is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Paste the code and properly format it instead. – JeffC Oct 19 '18 at 14:39

2 Answers2

2

Try

//div[contains(@class, 'dw-cal-slide') and contains(@class, 'dw-cal-slide-a')]//div[@data-full='2018-1-15']

But IMHO it's better (shorter expression) to use CSS selector

div.dw-cal-slide.dw-cal-slide-a div[data-full='2018-1-15']

If you want to locate ancestor and descendant div in two code lines, then you can use (Python example)

ancestor = driver.find_element_by_xpath("//div[contains(@class, 'dw-cal-slide') and contains(@class, 'dw-cal-slide-a')]")

and

descendant = ancestor.find_element_by_xpath(".//div[@data-full='2018-1-15']")
Andersson
  • 51,635
  • 17
  • 77
  • 129
0

As you said, there are multiple node with same property and only one is clickable. you can click on the node by checking isEnable. other thing you can try with following-sibling or preceding-sibling. example can be found on below stackoverflow link:

How to use XPath preceding-sibling correctly