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-containerfor <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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -