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

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

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

import org.openqa.selenium.WebElement;

class SiCommandExecutorVerifyValue extends SiCommandExecutor implements ISiCommandExecutorFlagUi {

    @Override
    public void beforeExecute(SiCommand command, SiContext siContext) throws SiVerifyException, SiWebDriverException {
        super.beforeExecute(command, siContext);
        siContext.getExecutorManager().getBasicExecutor("waitForElementPresent").execute(command, siContext);
        siContext.getExecutorManager().getBasicExecutor("waitForElementVisible").execute(command, siContext);
    }

    @Override
    public void execute(SiCommand command, SiContext siContext) throws SiVerifyException, SiWebDriverException {
        String expected = siContext.dynamic(command.getSiModelCommand().getValue(), "", "").trim();
        WebElement element = command.getTargetElement();
        String actual = element.getAttribute("value").trim();

        siContext.getReporter().reportMessage("expected: [" + expected + "]");
        siContext.getReporter().reportMessage("actual: [" + actual + "]");
        if (!actual.equals(expected)) {
            throw new SiVerifyException(
                    "Assert fail:\r\n" +
                            "\tExpected: [" + expected + "]\r\n" +
                            "\tActual: [" + actual + "]");
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy