Search in sources :

Example 6 with Lorsque

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

the class CommonSteps method waitStalenessOf.

/**
 * Waits staleness of element with timeout of x seconds.
 *
 * @param page
 *            The concerned page of field
 * @param element
 *            is key of PageElement concerned
 * @param time
 *            is custom timeout
 * @param conditions
 *            list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws TechnicalException
 *             is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
 */
@Conditioned
@Lorsque("J'attends la diparition de '(.*)-(.*)' avec un timeout de '(.*)' secondes[\\.|\\?]")
@Then("I wait staleness of '(.*)-(.*)' with timeout of '(.*)' seconds[\\.|\\?]")
public void waitStalenessOf(String page, String element, int time, List<GherkinStepCondition> conditions) throws TechnicalException {
    final WebElement we = Utilities.findElement(Page.getInstance(page).getPageElementByKey('-' + element));
    Context.waitUntil(ExpectedConditions.stalenessOf(we), time);
}
Also used : WebElement(org.openqa.selenium.WebElement) Lorsque(cucumber.api.java.fr.Lorsque) Conditioned(com.github.noraui.cucumber.annotation.Conditioned) Then(cucumber.api.java.en.Then)

Example 7 with Lorsque

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

the class LogoGameSteps method checkThatAllBrandsIsNotProhibited.

/**
 * A check that all brands are not prohibited, because any minors can not play with alcohol and tobacco brands.
 *
 * @param jsonLogos
 *            Serialized Json representation of all logos (all brands)
 * @throws TechnicalException
 *             is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
 * @throws FailureException
 *             if the scenario encounters a functional error
 */
@Lorsque("Je vérifie que toutes les marques '(.*)' ne sont pas interdites")
@Given("I check that all brands '(.*)' are not prohibited")
public void checkThatAllBrandsIsNotProhibited(String jsonLogos) throws TechnicalException, FailureException {
    Logos logos = new Logos();
    logos.deserialize(jsonLogos);
    for (int i = 0; i < logos.size(); i++) {
        if (ProhibitedBrands.getAlcool().contains(logos.get(i).getBrand()) || ProhibitedBrands.getTabaco().contains(logos.get(i).getBrand())) {
            new Result.Failure<>(logos.get(i).getBrand(), Messages.format("Brand « %s » is prohibited.", logos.get(i).getBrand()), false, logos.get(i).getNid(), Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
        }
    }
}
Also used : Logos(com.github.noraui.application.model.logogame.Logos) Lorsque(cucumber.api.java.fr.Lorsque) Given(cucumber.api.java.en.Given)

Aggregations

Lorsque (cucumber.api.java.fr.Lorsque)7 Then (cucumber.api.java.en.Then)5 Conditioned (com.github.noraui.cucumber.annotation.Conditioned)4 AssertError (com.github.noraui.exception.AssertError)2 TechnicalException (com.github.noraui.exception.TechnicalException)2 GherkinStepCondition (com.github.noraui.gherkin.GherkinStepCondition)2 Given (cucumber.api.java.en.Given)2 File (java.io.File)2 WebElement (org.openqa.selenium.WebElement)2 Logos (com.github.noraui.application.model.logogame.Logos)1