Search in sources :

Example 1 with Alors

use of cucumber.api.java.fr.Alors in project NoraUi by NoraUi.

the class LogoGameSteps method saveScore.

@Alors("Je sauvegarde le score")
@Then("I save score")
public void saveScore() throws FailureException {
    try {
        WebElement message = Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(this.logoGamePage.scoreMessage)));
        try {
            Context.getCurrentScenario().write("score is:\n" + message.getText());
            Context.getDataOutputProvider().writeDataResult("score", Context.getDataInputProvider().getIndexData(Context.getCurrentScenarioData()).getIndexes().get(0), message.getText());
        } catch (TechnicalException e) {
            logger.error(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE), e);
        }
    } catch (Exception e) {
        new Result.Failure<>(e.getMessage(), "", true, this.logoGamePage.getCallBack());
    }
}
Also used : TechnicalException(com.github.noraui.exception.TechnicalException) WebElement(org.openqa.selenium.WebElement) FailureException(com.github.noraui.exception.FailureException) TechnicalException(com.github.noraui.exception.TechnicalException) Result(com.github.noraui.exception.Result) Alors(cucumber.api.java.fr.Alors) Then(cucumber.api.java.en.Then)

Example 2 with Alors

use of cucumber.api.java.fr.Alors in project NoraUi by NoraUi.

the class LogoGameSteps method playWithMyInputFile.

@Alors("Je joue avec mon fichier d'entrée '(.*)'")
@Then("I play with my input file '(.*)'")
public void playWithMyInputFile(String jsonLogos) throws TechnicalException {
    Logos logos = new Logos();
    logos.deserialize(jsonLogos);
    for (int i = 0; i < logos.size(); i++) {
        Logo logo = logos.get(i);
        logo.setNid(i);
        try {
            WebElement element = getDriver().findElement(Utilities.getLocator(this.logoGamePage.brandElement, logo.getBrand(), logo.getBrand()));
            if (element != null) {
                updateText(this.logoGamePage.brandElement, logo.getBrand(), null, logo.getBrand(), logo.getBrand());
            }
        } catch (Exception e) {
            new Result.Warning<>(logo.getBrand(), Messages.format("Brand « %s » does not exist.", logo.getBrand()), true, logo.getNid());
        }
    }
}
Also used : Logos(com.github.noraui.application.model.logogame.Logos) WebElement(org.openqa.selenium.WebElement) FailureException(com.github.noraui.exception.FailureException) TechnicalException(com.github.noraui.exception.TechnicalException) Logo(com.github.noraui.application.model.logogame.Logo) Result(com.github.noraui.exception.Result) Alors(cucumber.api.java.fr.Alors) Then(cucumber.api.java.en.Then)

Aggregations

FailureException (com.github.noraui.exception.FailureException)2 Result (com.github.noraui.exception.Result)2 TechnicalException (com.github.noraui.exception.TechnicalException)2 Then (cucumber.api.java.en.Then)2 Alors (cucumber.api.java.fr.Alors)2 WebElement (org.openqa.selenium.WebElement)2 Logo (com.github.noraui.application.model.logogame.Logo)1 Logos (com.github.noraui.application.model.logogame.Logos)1