Home > database >  XPath, nested conditions
XPath, nested conditions

Time:01-27

I have the following HTML code, and I need to have an XPath expression, which finds the table element.

<div>
   <div>Dezember</div>
   <div>
       <div >more divs</div>
   </div>
</div>

My current Xpath expression:

//div[./div[1]/text() = "Dezember"]/preceding::div[./div[2][@class=dash-table-container]

I don't know how to check if the dash table container is the last one loaded, since I have many of them. So I need the check if it's under the div with "Dezember" as a text because the div's before with the other months are being loaded faster. I want the XPATH to select the "dash table container" div. Thanks in advance

CodePudding user response:

To select the div with the text content of "more divs", you can use

//div/div[@ and ../preceding-sibling::div[1]="Dezember"]

and to select its parent div element, use

//div[div/@][preceding-sibling::div[1]="Dezember"]/..

CodePudding user response:

I figured it out.

//div[preceding-sibling::div="Dezember"]/div[@]

worked perfectly for me.

  •  Tags:  
  • Related