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

com.github.siwenyan.si.SiCommandExecutorStoreXpathCount Maven / Gradle / Ivy

There is a newer version: 1.25.1.0
Show newest version
package com.github.siwenyan.si;

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

import java.util.List;

class SiCommandExecutorStoreXpathCount extends SiCommandExecutor {

    @Override
    public void execute(SiCommand command, SiContext siContext) throws SiVerifyException, SiWebDriverException {
        String xpath = siContext.dynamic(command.getSiModelCommand().getTarget(), "", "");
        List els = siContext.asWebDriver().findElements(By.xpath(xpath));

        String name = command.getSiModelCommand().getValue();
        String value = "" + (null == els ? 0 : els.size());

        siContext.getReporter().reportMessage("name: " + name);
        siContext.getReporter().reportMessage("value: " + value);

        siContext.addVar(name, value);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy