Skip to content

Cannot attach Selenide screenshot into allure 2.0 report #215

Closed

Description

@dimencionrider

I want to attach a screenshot of my failed test into allure report.

I'm using:

  • java
  • gradle
  • selenide
  • allure 2.0
  • testNG

For better understanding, here is the tool, I'm working on: https://youtu.be/X9ubuj2k7bQ

Here is the path to selenide screenshots:
.../myProject/build/reports/tests/pic.png

Here is the path to allure-results folder:
.../myProject/target/allure-results/....testsuite.xml

Can someone help me to fix the issue, or provide the correct way of implementation?

Conclusion:
I would like to have at the end - run the command "allure serve .../myProject/target/allure-results/"
and screenshots should be shown under my failed tests allure report section.

Thanks,
Roman

Activity

  1. baev commented on Apr 6, 2018

    @baev
    Member

    Allure knows nothing about screenshots from Selenide, so you need to save screenshots using Allure API.

    Also you can consider using Allure Selenide integration, that will do all the work for you https://docs.qameta.io/allure/#_selenide

  2. dimencionrider commented on Apr 6, 2018

    @dimencionrider
    Author

    Selenide listener does not work for me. It cannot download sources from maven repository.

    import io.qameta.allure.selenide.AllureSelenide; - showing red colour in my IDEA

    any other ways? or workarounds?

  3. baev commented on Apr 6, 2018

    @baev
    Member

    hm https://repo.maven.apache.org/maven2/io/qameta/allure/allure-selenide/2.6.0/

    Have you added dependency? Try to invalidate caches for IDEA and restart

  4. rosolko commented on Apr 6, 2018

    @rosolko

    @baev @dimencionrider Just not that 2.6.0 version can't configure screenshots and savePageSource properties because that was added after release.

  5. dimencionrider commented on Apr 6, 2018

    @dimencionrider
    Author

    in my build.gradle file I have this dependency:

    compile group: 'io.qameta.allure', name: 'allure-selenide', version: '2.0-BETA22'

    here is screenshot of my method: https://prnt.sc/j1qc5e
    I cannot import AllureSelenide()

  6. rosolko commented on Apr 6, 2018

    @rosolko

    @dimencionrider change version to 2.6.0

  7. dimencionrider commented on Apr 10, 2018

    @dimencionrider
    Author

    @baev @rosolko does not work with 2.6.0

  8. janeberets commented on Apr 30, 2018

    @janeberets

    @baev @rosolko Class AllureSelenide.java has not method 'screenshots' in tag 2.6.0. But in branch master - it has. Is it normal?

  9. rosolko commented on May 7, 2018

    @rosolko

    @janeberets It's weird. Because readme file updated with new features, but released the old one :(

  10. rosolko commented on Jun 7, 2018

    @rosolko

    @baev Can you please release 2.6.1 or 2.7.0 version with latest selenide ext version?

  11. simple-elf commented on Jun 24, 2018

    @simple-elf
    Contributor

    @rosolko @dimencionrider @janeberets you can use 2.6.0 version. There is screenshots config value true by default

    SelenideLogger.addListener("AllureSelenide", new AllureSelenide());
    
  12. symonk commented on Jul 9, 2018

    @symonk

    @dimencionrider
    you can use the default as above which will include screenshots, or you can implement LogEventListener and pass the concrete implementation to SelenideLogger.addListener("foo", new concreteImpl());

    allure will release soon i guess and make it simple to have the fluent capabilities. Here is an example I implemented my own listener to include screenshot, page source and a .json log file per threaded test

    https://github.com/symonk/Selenide-TestNG-Allure2-Framework/blob/master/gui-tests/src/test/java/io.github.symonk/configurations/selenide/CustomListener.java

    example: new CustomListener().withPageSource(true).withScreenshot(true).withTestLog(true);

  13. simple-elf commented on Jul 26, 2018

    @simple-elf
    Contributor

    @dimencionrider @rosolko 2.7.0 released - https://github.com/allure-framework/allure-java/releases/tag/2.7.0
    So now you can write like in docs https://docs.qameta.io/allure/#_selenide

    import io.qameta.allure.selenide.AllureSelenide;
    ...
    SelenideLogger.addListener("AllureSelenide", new AllureSelenide().screenshots(true).savePageSource(false));
    

    Also you can disable standart selenide screenshoots by Configuration.screenshots = false because it will just dublicates files.

    @dimencionrider Do you have any other questions or problems? Can we close this issue?

  14. baev commented on Oct 18, 2018

    @baev
    Member

    thats looks like configuration issue. If you still having issues with that please asking a question in our community chat https://gitter.im/allure-framework/allure-core

  15. amardeep2006 commented on Oct 30, 2024

    @amardeep2006

    I recently faced similar issue with TestNG and could not resolve with
    SelenideLogger.addListener("AllureSelenide", new AllureSelenide().screenshots(true).savePageSource(true));
    as my use case was to Take screenshots for successful cases .

    Finally this worked for me (may not be the best solution ) but it may be helpful to someone who reach here via Search engine.

        public byte[] captureScreenshot() throws IOException {
            // Generate a random filename using UUID
            String randomFileName = "screenshot-" + UUID.randomUUID().toString();
            Selenide.screenshot(randomFileName).getBytes(StandardCharsets.UTF_8);
            File screenshot = Screenshots.getLastScreenshot();
            return screenshot == null ? null : Files.toByteArray(screenshot);
        }

    This Reference for Junit was helpful but did not solve for TestNG. https://github.com/selenide-examples/selenide-allure-junit/tree/main

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions