How to get the parent of an element in webdriver -
<div class="field select-container invalid" data-tooltip="error message." "name="birthdate"> <div class="stack-wrap gutter-col-wrap-1"> <div class="stack size1of3"> <div class="gutter-col-1"> <div class="form-selectbox full-width"> <select name="day"> <option value="">giorno</option> <option value="01">1</option>
when used webelement el = browser.switchto().activeelement(), focus on "name" attribute. need find parent "data-tooltip" in order error message on screen. please help.
if understand question correctly, want find data-tooltip's text div.select-container
for <select name="day">'
only
here's how in java xpath's ancestor selector (untested code):
webelement selectdaycontainer = driver.findelement(by.xpath("//select[@name='day']//ancestor::div[contains(@class, 'select-container')]")); string tooltip = selectdaycontainer.getattribute("data-tooltip");
Comments
Post a Comment