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.
& Lt; Td width = "50%" & gt; & Lt; / Td> & Lt; Td width = "7%" & gt; & Lt; / Td> & Lt; Td width = "20%" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; & Lt; / Div & gt; & Lt; Div class = "verb" & gt; & Lt; Form method = "post" data-remote = "true" action = "/ commitments / get_view" accept-letterset = "UTF-8" & gt; & Lt; Div style = "margin: 0; padding: 0; display: inline" & gt; & Lt; / Div & gt; & Lt; Input id = "col_type" type = "hidden" value = "col_my_work_commitments" name = "col_type" & gt; & Lt; / Input & gt; & Lt; Input id = "card_id" type = "hidden" value = "174" name = "card_id" & gt; & Lt; / Input & gt; & Lt; Input id = "state" type = "hidden" value = "Published" name = "state" & gt; & Lt; / Input & gt; & Lt; Table width = "100%" & gt; & Lt; Tbody & gt; & Lt; Tr class = "actions" & gt; & Lt; TD & gt; & Lt; Button ID = "commitments-identifier" type = "submit" name = "btn_discuss" & gt; & Lt; / Button & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; & Lt; / Form & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Section & gt;
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
Post a Comment