Skip to content

AllureSelenide configuration for screenshots and page source#202

Merged
baev merged 2 commits into
allure-framework:masterfrom
simple-elf:selenide
Feb 16, 2018
Merged

AllureSelenide configuration for screenshots and page source#202
baev merged 2 commits into
allure-framework:masterfrom
simple-elf:selenide

Conversation

@simple-elf
Copy link
Copy Markdown
Contributor

//: # (
. Thank you so much for sending us a pull request!
.
. Make sure you have a clear name for your pull request.
. The name should start with a capital letter and no dot is required in the end of the sentence.
. To link the request with isses use the following notation: (fixes #123, fixes #321)
.
. An example of good pull request names:
. - Add Russian translation (fixes #123)
. - Add an ability to disable default plugins
. - Support emoji in test descriptions
)

Context

Added configuration for save screenshots and page sources to Allure report or not.

SelenideLogger.addListener("AllureSelenide", new AllureSelenide().screenshots(true).savePageSource(false));

Checklist

@simple-elf
Copy link
Copy Markdown
Contributor Author

Also changes in allure-docs allure-framework/allure-docs#93

@baev
Copy link
Copy Markdown
Member

baev commented Feb 16, 2018

@simple-elf please fix the build

@baev baev merged commit 9a50e32 into allure-framework:master Feb 16, 2018
@baev
Copy link
Copy Markdown
Member

baev commented Feb 16, 2018

@simple-elf thanks!

@simple-elf simple-elf deleted the selenide branch February 16, 2018 16:00
@rosolko
Copy link
Copy Markdown

rosolko commented Feb 17, 2018

@simple-elf @baev This PR override configuration from Selenide config.
So if I’m set config in any other place this listener override it.
I think that better solution will be direct:

  1. Create 2 constructors - empty and with two current params
  2. Do nothing in empty constructor
  3. Update Selenide configuration inside all arg constructor and remove class fields.
  4. In code(on event) look for configuration value, so both behaviors will work. Default from selenide and user defined. And custom listener config.

@rosolko
Copy link
Copy Markdown

rosolko commented Feb 18, 2018

@simple-elf @baev
I mean something like that:

public class AllureSelenide implements LogEventListener {
    private final AllureLifecycle lifecycle;

    public AllureSelenide() {
        this(Allure.getLifecycle());
    }

    public AllureSelenide(final AllureLifecycle lifecycle) {
        this.lifecycle = lifecycle;
    }

    public AllureSelenide screenshots(final boolean saveScreenshots) {
        Configuration.screenshots = saveScreenshots;
        return this;
    }

    public AllureSelenide savePageSource(final boolean savePageHtml) {
        Configuration.savePageSource = savePageHtml;
        return this;
    }

    @Override
    public void onEvent(final LogEvent event) {
                ...
                if (Configuration.screenshots) {
                    lifecycle.addAttachment("Screenshot", "image/png", "png", getScreenshotBytes());
                }
                if (Configuration.savePageSource) {
                    lifecycle.addAttachment("Page source", "text/html", "html", getPageSourceBytes());
                }
                ...
    }

@simple-elf
Copy link
Copy Markdown
Contributor Author

Like I said in #198 with selenide screenshots configuration files will be dublicates in allure-results folder and in selenide folder fo screenshots (and page htmls). For using this integration you need to set Configuration.screenshots = false - and you will get screenshots in allure-results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enum class cast exception when using varargs generic constant parameter in step

3 participants