我在使用带有appium的Screenplay模式时遇到了Serenity BDD的问题(我使用的是Appium 1.3.1),项目在每一步都没有生成截图,生成的报告没有显示步骤的捕获,但在我的代码中,我在IDE中没有任何问题或错误,这是我的代码和Serenity报告的捕获:
import net.serenitybdd.junit.runners.SerenityRunner;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.abilities.BrowseTheWeb;
import net.serenitybdd.screenplay.questions.page.TheWebPage;
import net.thucydides.core.annotations.Issue;
import net.thucydides.core.annotations.Managed;
import net.thucydides.core.annotations.Screenshots;
import net.thucydides.core.annotations.Steps;
import net.thucydides.core.annotations.findby.By;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.Otherpackage.tasks.OpenTheApplication;
import com.Otherpackage.tasks.Search;
import com.Otherpackage.tasks.escribeNombre;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import static net.serenitybdd.screenplay.GivenWhenThen.*;
import static net.serenitybdd.screenplay.EventualConsequence.eventually;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItem;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
@RunWith(SerenityRunner.class)
public class SearchByKeywordStory {
Actor anna = Actor.named("Anna");
@Managed
public static AppiumDriver<WebElement> herBrowser;
@Steps
OpenTheApplication openTheApplication;
@Before
public void annaCanBrowseTheWeb() {
anna.can(BrowseTheWeb.with(herBrowser));
}
@Test
public void search_results_should_show_the_search_term_in_the_title() throws
MalformedURLException, InterruptedException {
String packagename = "com.facebook.katana";
String URL="http://127.0.0.1:4723/wd/hub";
String activityname = "com.facebook.katana.LoginActivity";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Galaxy S5");
capabilities.setCapability("udid", "284596bb");
capabilities.setCapability("platformVersion", "8.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", packagename);
capabilities.setCapability("appActivity", activityname);
capabilities.setCapability("noReset", true);
herBrowser= new AndroidDriver<WebElement>(new URL(URL), capabilities);
herBrowser.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
Thread.sleep(4000);
when(anna).attemptsTo(escribeNombre.yacasi());
}
}
这是包含Step:
的另一个类“escribeNombre”package com.Otherpackage.tasks;
import static net.serenitybdd.screenplay.Tasks.instrumented;
import static org.openqa.selenium.Keys.ENTER;
import org.openqa.selenium.WebElement;
import com.accenture.features.search.SearchByKeywordStory;
import com.accenture.ui.SearchBox;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Task;
import net.serenitybdd.screenplay.actions.Click;
import net.serenitybdd.screenplay.actions.Enter;
import net.thucydides.core.annotations.Step;
public class escribeNombre implements Task {
@Step("Abre la App y busca nombre")
public <T extends Actor> void performAs(T actor) {
WebElement num3 =
SearchByKeywordStory.herBrowser.findElementByClassName
("android.widget.EditText"); //Click a la barra de busqueda.
num3.sendKeys("Daniel Correa \n");
}
public static escribeNombre yacasi() {
return instrumented(escribeNombre.class);
}
}
这是Serenity Report,不会在步骤中截取任何截图 https://i.imgur.com/uKkMGeE.png
任何人都可以帮助我吗?在网页上,它几乎没有关于将其与appium http://thucydides.info/docs/serenity-staging/#_running_tests_on_appium
一起使用的文档如果你有和appium平静的例子将对我有很大的帮助
感谢阅读并抱歉我的硬编码
答案 0 :(得分:-1)
您可以尝试在serenity.properties文件中设置serenity.take.screenshots = AFTER_EACH_STEP吗?
您可以关注有关screenshots are not found in the serenity report的主题。
这给出了有关在报告中获取屏幕截图的想法。