All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jp.vmi.selenium.selenese.subcommand.IsSomethingSelected Maven / Gradle / Ivy

package jp.vmi.selenium.selenese.subcommand;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import jp.vmi.selenium.selenese.Context;

import static jp.vmi.selenium.selenese.command.ArgumentType.*;

/**
 * Alternative IsSomethingSelected.
 */
public class IsSomethingSelected extends AbstractSubCommand {

    private static int ARG_SELECT_LOCATOR = 0;

    /**
     * Constructor.
     */
    public IsSomethingSelected() {
        super(LOCATOR);
    }

    @Override
    public Boolean execute(Context context, String... args) {
        WebElement select = context.getElementFinder().findElement(context.getWrappedDriver(), args[ARG_SELECT_LOCATOR]);
        List options = select.findElements(By.tagName("option"));
        for (WebElement option : options)
            if (option.isSelected())
                return true;
        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy