You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Serenity BDD结合Appium Screenplay模式不生成步骤截图问题求助

Hey there! Let’s work through this screenshot issue with Appium 1.3.1 and Serenity BDD Screenplay together— I’ve dealt with similar head-scratchers before, so here are the key fixes to check first:

1. Double-Check Serenity Configuration Settings

Serenity needs explicit properties to enable step-level screenshots. Open your serenity.properties (or serenity.conf if using HOCON) and confirm these settings are present:

# Critical: Enables screenshots after every step (default is only on failure)
serenity.take.screenshots=AFTER_EACH_STEP
# Bind to Appium driver
serenity.driver.capabilities=appium
# Match your device setup (adjust for iOS if needed)
serenity.appium.driver.capabilities.platformName=Android
serenity.appium.driver.capabilities.deviceName=emulator-5554

If using a .conf file, the HOCON syntax would be:

serenity {
  take {
    screenshots = "AFTER_EACH_STEP"
  }
  driver {
    capabilities = "appium"
  }
  appium {
    driver {
      capabilities {
        platformName = "Android"
        deviceName = "emulator-5554"
      }
    }
  }
}
2. Ensure Your Actor Is Properly Linked to Appium Driver

In Screenplay, screenshots rely on the Actor having the BrowseTheWeb ability bound to a valid Appium driver. If you’re initializing the driver manually, make sure you’re assigning it correctly to the Actor:

import io.appium.java_client.android.AndroidDriver;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.abilities.BrowseTheWeb;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;

public class MobileActorSetup {
    public static Actor createActor(String actorName) throws Exception {
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("platformName", "Android");
        caps.setCapability("deviceName", "emulator-5554");
        caps.setCapability("app", "/path/to/your/app.apk");

        AndroidDriver driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), caps);
        Actor actor = Actor.named(actorName);
        // This line is critical— don't skip it!
        actor.can(BrowseTheWeb.with(driver));
        return actor;
    }
}

If using Serenity’s managed drivers, ensure your config is set up so Serenity automatically injects the Appium driver into the Actor.

3. Validate Task/Interaction Step Annotations

Serenity only captures screenshots for actions it recognizes as steps. For custom tasks, add the @Step annotation to make Serenity aware:

import net.serenitybdd.screenplay.Task;
import net.serenitybdd.screenplay.actions.Click;
import net.thucydides.core.annotations.Step;

public class LoginActions {
    // Built-in interactions (like Click) are already step-aware
    public static Task enterUsername(String username) {
        return Task.where("{0} enters username: " + username,
                Click.on(LoginPage.USERNAME_FIELD).thenEnter(username)
        );
    }

    // Custom task methods need @Step to trigger screenshots
    @Step("{0} taps the login button")
    public static Task tapLoginButton() {
        return Task.where("", Click.on(LoginPage.LOGIN_BUTTON));
    }
}

Without these annotations or using the Task.where() structure, Serenity won’t trigger screenshot captures for your actions.

4. Check Appium-Serenity Compatibility

Appium 1.3.1 is quite outdated (released in 2015), and newer Serenity versions (2.x+) might have compatibility gaps. Try downgrading Serenity to a version that’s known to work with older Appium builds, like the 1.9.x series. For Maven, update your pom.xml:

<dependencies>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>1.9.49</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-screenplay</artifactId>
        <version>1.9.49</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-appium</artifactId>
        <version>1.9.49</version>
    </dependency>
</dependencies>
5. Verify Screenshot Files Exist (and Regenerate the Report)

Sometimes screenshots are generated but don’t show up in the report. Check the target/site/serenity/screenshots folder after running tests— if you see image files there, the issue is with report rendering. Try regenerating the report:
For Maven:

mvn clean serenity:aggregate

For Gradle:

gradle clean aggregate

Also, delete the target folder before re-running tests to avoid cached data interfering.

6. Avoid Manual Driver Lifecycle Management

If you’re manually calling driver.quit() in your code, you might be closing the driver before Serenity can capture screenshots. Let Serenity handle driver lifecycle through the SerenityRunner— don’t manually terminate the driver unless absolutely necessary.


If none of these fix the issue, sharing a bit more of your task/interaction code and full serenity.properties would help narrow things down further.

内容的提问来源于stack exchange,提问作者renzo.barrios1407

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:10:42