0
    WebElement statusArr[]=new WebElement[6];
    String arr[] = new String[6];       
    for(int i=0;i<6;i++)
    {
        int j = i+1;
        statusArr[i] = driver.findElement(By.xpath("//*[@id='body']/ui-view/div[1]/div/div["+j+"]/a/table/tbody/tr[1]/td/div/i"));
        arr[i] = statusArr[i].getAttribute("title");
    }
    for(int i=0;i<6;i++)
    {
        if(arr[i].equals("Not Provided")||arr[i].equals("Incomplete")){
            wait.until(ExpectedConditions.visibilityOfNestedElementsLocatedBy(statusArr[i], null));
            statusArr[i].click();
            driver.navigate().back();
        }
    }

Here i am trying to wait for the element to load and then click. But it is not possible. How can I do this?

1
  • Please post the relevant HTML and describe the scenario you are trying to accomplish. I think there's probably a better way to do this. That XPath locator is going to be very brittle as long as it is. Commented Dec 14, 2016 at 15:25

1 Answer 1

0

From visibilityOfNestedElementsLocatedBy docs

An expectation for checking child WebElement as a part of parent element to be visible

In visibilityOfNestedElementsLocatedBy(statusArr[i], null) you are basically waiting for null to be visible. Try visibilityOf instead

wait.until(ExpectedConditions.visibilityOf(statusArr[i]));

By the way, when you click on the element and navigate back you will loose the elements in statusArr[] and you will have to relocate them each iteration.

Sign up to request clarification or add additional context in comments.

2 Comments

What should i do about navigate then? If i relocate elements each time in iteration then how can I get the count number for which the loop was iterating?
@AniruddhaSupe Have a look at stackoverflow.com/questions/38366251/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.