Hello All,
This post tells about finding parent element of any element using Selenium/Web Driver. Many times we need to perform some action on elements based on their parents. This post will give you some idea to find out the parent element by using xpath.
Code:
//##################################################//
public WebElement GetParentElement(WebElement elem)
{
WebElement parentElem=null;
if(elem !=null)
{
parentElem=elem.findElement(By.xpath(".."));
}
return parentElem;
}
//##################################################//
This post tells about finding parent element of any element using Selenium/Web Driver. Many times we need to perform some action on elements based on their parents. This post will give you some idea to find out the parent element by using xpath.
Code:
//##################################################//
public WebElement GetParentElement(WebElement elem)
{
WebElement parentElem=null;
if(elem !=null)
{
parentElem=elem.findElement(By.xpath(".."));
}
return parentElem;
}
//##################################################//
No comments:
Post a Comment