How i can get the parent id in html code. In selenium webdirver using java -


How do I get the original ID inside the HTML code? I want to get the ID of that div using the description class name. Here the name of the card-box class for all cards and boxes is normal and is generated at run time.

   

For this, I tried this code

  string val1 = "final"; & Lt; WebElement & gt; ResultList1 = card1.find Elements (By.className ("description")); (WebAllement Results for: resultList1) {string tabam = results; .getText (); If (tabname.contentEquals (val1)) {System.out.println (description.getAttribute ("id")); ResultItem.click (); break; }}  

Assume that you have some WebElement el , And you want your parent to get WebElement , you can use it:

  el.findElement (By.xpath (".. "))  

To get the id of that element, you can use it:

  el.findElement (By.xpath ("..") GetAttribute ("id")  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -