I have tried below ways but no luck
Attempt 1 :
WebElement profile = dr.findElement(By.xpath("//ul[@id='wp-admin-bar-top-secondary']//a[@title='My Account']"));
WebElement logout = dr.findElement(By.xpath("//ul[@id='wp-admin-bar-user-actions']/li["+i+"]/a"));
Actions action = new Actions(dr);
action.moveToElement(profile).perform();
action.moveToElement(logout).click().perform();
Attempt 2 :
Actions action = new Actions(dr);
action.moveToElement(profile).click(logout).perform();
Attempt 3 :
Actions action = new Actions(dr);
action.moveToElement(profile).perform();
List<WebElement> l = dr.findElements(By.xpath(".//*[@id='wp-admin-bar-user-actions']/li"));
for(int i=0;i<=l.size()-1;i++){
WebElement s = l.get(i);
System.out.println(l.get(i).getText());
if(s.getText().equalsIgnoreCase("logout")){
// WebElement logout = dr.findElement(By.xpath("//ul[@id='wp-admin-bar-user-actions']/li["+i+"]/a"));
action.moveToElement(dr.findElement(By.xpath("//ul[@id='wp-admin-bar-user-actions']/li["+i+"]/a"))).click().build().perform();
//s.click();
}
}
Please help me on this, what could be the issue.