Giter Club home page Giter Club logo

allure-qaguru's People

Contributors

eroshenkoam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

allure-qaguru's Issues

Пишем простой тест на Selenide

Добавляем зависимости:

compile 'com.codeborne:selenide:5.11.1'

compile("org.junit.jupiter:junit-jupiter-api:5.6.2")
compile("org.junit.jupiter:junit-jupiter-engine:5.6.2")
compile("org.junit.jupiter:junit-jupiter-params:5.6.2")

Обозначаем входные параметры:

private final static String REPOSITORY = "eroshenkoam/allure-example";
private final static String USER = "eroshenkoam";
private final static int ISSUE_NUMBER = 12;

Пишем простой тест на Selenide:

open("https://github.com");
$(".header-search-input").click();
$(".header-search-input").sendKeys("eroshenkoam/allure-example");
$(".header-search-input").submit();
$(By.linkText("eroshenkoam/allure-example")).click();
$(withText("Issues")).click();
$(withText("#12")).should(Condition.exist);

Заменяем степы на Listener

Добавляем зависимости:

compile 'io.qameta.allure:allure-selenide:2.13.3'

Добавляем Listener в тесты:

@Before
public void initSelenideListener() {
    SelenideLogger.addListener("allure", new AllureSelenide().screenshots(true));
}

Добавляем именованные элементы:

public class NamedBy extends By {
    
    private final By by;
    private String name;

    public NamedBy(final By by) {
        this.by = by;
    }
    
    public NamedBy as(final String name) {
        this.name = name;
        return this;
    }

    @Override
    public List<WebElement> findElements(final SearchContext context) {
        return this.by.findElements(context);
    }
    
    public String toString() {
        return Optional.ofNullable(name).orElseGet(by::toString);
    }
    
    public static NamedBy css(final String value) {
        return new NamedBy(By.cssSelector(value));
    }
    
}

Добавляем дополнительную разметку в виде step методов

Создаем класс BaseSteps:

public class BasicSteps {

    @Step("Открываем главную страницу")
    public void openMainPage(String user) {
        parameter("user", user);
        open("https://github.com");
    }

    @Step("Открываем страницу с репозиторием")
    public void searchForRepository(String name) {
        parameter("Repository", name);
        $(".header-search-input").click();
        $(".header-search-input").sendKeys(name);
        $(".header-search-input").submit();
        $(By.linkText(name)).click();
    }

    @Step("Открываем страницу с задачами в репозитории")
    public void openRepositoryIssues() {
        $(withText("Issues")).click();
    }

    @Step("Проверяем наличие задачи c id")
    public void shouldSeeIssueWithId(int number) {
        parameter("Issue Number", number);
        $(withText("#12")).should(Condition.exist);
    }
}

Добавляем сценарий теста:

steps.openMainPage(USER);
steps.searchForRepository(REPOSITORY);
steps.openRepositoryIssues();
steps.shouldSeeIssueWithId(ISSUE_NUMBER);

Добавляем дополнительную разметку

Изменяем сценарий теста:

step("Открываем главную страницу", () -> {
    open("https://github.com");
});
step("Открываем страницу с репозиторием", () -> {
    $(".header-search-input").click();
    $(".header-search-input").sendKeys("eroshenkoam/allure-example");
    $(".header-search-input").submit();
    $(By.linkText("eroshenkoam/allure-example")).click();
});
step("Открываем страницу с задачами в репозитории", () -> {
    $(withText("Issues")).click();
});
step("Проверяем наличие задачи с ID=" + ISSUE_NUMBER, () -> {
    $(withText("#12")).exists();
});

Добавляем параметры теста:

parameter("User", USER);
parameter("Repository", REPOSITORY);
parameter("Issue Number", ISSUE_NUMBER);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.