Find inactive element (Javascript) and click only on inactive element Selenium Java

public void inactive throws exceptions ()
{
    List<WebElement> myElements = driver.findElements(By.xpath("/html/body/div[2]/div[6]/div/table"));
    System.out.println("Size of List: " + myElements.size());
    for (WebElement e : myElements) {

        System.out.print("Text within the Anchor tab" + e.getText() + "\t");
        System.out.println("Anchor: " + e.getAttribute("href"));

        ((JavascriptExecutor) driver).executeScript("scroll(0,400)").equals("href=\"javascript:toggleEnabled");
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(text(), 'Inactive")));

    }

I am not able to find the inactive element (a.herf) and click only on to the particular in-active element. How to find the element on toggle.Enabled JavaScript and click only on title = "Inactive" status form list? HTML Console code is mentioned below.

<a href="javascript:toggleEnabled('Collaboration Browse -> Browse');">
    <img src="/console/themes/images/new_imgs/status_light_off.png" 
         style="width:24px; height:24px;" alt="Inactive" title="Inactive">
</a>

1 answer

  • answered 2018-01-14 10:33 nick318

    As I understand your problem, try this one:

    List<WebElement> list = driver.findElements(By.xpath(".//a/img[@title='Inactive']"));
    
    list.forEach(WebElement::click);