net.serenitybdd.screenplay.Actor Java Examples

The following examples show how to use net.serenitybdd.screenplay.Actor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlaceOrder.java    From bdd-trader with Apache License 2.0 7 votes vote down vote up
@Override
public <T extends Actor> void performAs(T actor) {

    Integer portfolioId = actor.asksFor(ThePortfolio.idFor(client));

    actor.attemptsTo(
            Post.to(BDDTraderEndPoints.PlaceOrder.path())
                    .with(request -> request.header("Content-Type", "application/json")
                            .body(Trade.of(buyOrSell, quantity)
                                       .sharesOf(securityCode)
                                       .at(price)
                                       .dollarsEach())
                            .pathParam("portfolioId",portfolioId)
                    )
    );

    actor.should(seeThat(TheResponse.statusCode(), equalTo(200)));

}
 
Example #2
Source File: CurrentFilter.java    From serenity-documentation with Apache License 2.0 6 votes vote down vote up
@Override
public TodoStatusFilter answeredBy(Actor actor) {
    return Text.of(FilterSelection.SELECTED_FILTER).viewedBy(actor).asEnum(TodoStatusFilter.class);
}
 
Example #3
Source File: ProjectWidgetDetails.java    From jenkins-build-monitor-plugin with MIT License 6 votes vote down vote up
@Override
public String answeredBy(Actor actor) {
    Target details    = BuildMonitorDashboard.Project_Widget_Details.of(projectName);

    return Text.of(details).viewedBy(actor).resolve();
}
 
Example #4
Source File: ProjectWidgetPipelineStages.java    From jenkins-build-monitor-plugin with MIT License 6 votes vote down vote up
@Override
public String answeredBy(Actor actor) {
    Target details = BuildMonitorDashboard.Project_Widget_Pipeline_Stages.of(projectName);

    return Text.of(details).viewedBy(actor).resolve();
}
 
Example #5
Source File: CreateRepository.java    From base_project_for_web_automation_projects with MIT License 6 votes vote down vote up
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            Click.on(NEW_REPOSITORY),
            Enter.theValue(repository.name()).into(REPOSITORY_NAME)
    );

    actor.should(seeThat(the(MESSAGE_REPOSITORY_ALREADY_EXISTS), isNotVisible())
            .orComplainWith(RepositoryAlreadyExistsError.class,
                    withMessageBy(repository.name())));

    actor.attemptsTo(
            Check.whether(isNotEmptyOrNull(repository.description()))
                    .andIfSo(Enter.theValue(repository.description()).into(REPOSITORY_DESCRIPTION)),
            Check.whether(repository.isInitializeWithREADME())
                    .andIfSo(Click.on(INITIALIZE_THIS_REPOSITORY_WITH_README)),
            Scroll.to(CREATE_REPOSITORY),
            Check.whether(repository.gitIgnore() != NONE)
                    .andIfSo(SelectDropDownButton.addGitIgnoreFilteringBy(repository.gitIgnore())),
            Check.whether(repository.license() != License.NONE)
                    .andIfSo(SelectDropDownButton.addLicenseFilteringBy(repository.license())),
            Click.on(CREATE_REPOSITORY)
    );
}
 
Example #6
Source File: Start.java    From base_project_for_web_automation_projects with MIT License 6 votes vote down vote up
@Override
@Step("{0} performs an authentication")
public <T extends Actor> void performAs(T theActor) {
    theActor.attemptsTo(Open.browserOn(gitHubLoginPage));

    theActor.should(seeThat(the(USERNAME_OR_EMAIL_ADDRESS), isVisible())
            .orComplainWith(StartError.class,
                    MESSAGE_LOGIN_PAGE_NOT_LOADED));

    theActor.attemptsTo(
            Enter.theValue(user.getUsername()).into(USERNAME_OR_EMAIL_ADDRESS),
            EnterAndHide.theValue(user.getPassword()).as("a password").into(PASSWORD),
            Click.on(SIGN_IN));

    theActor.should(seeThat(the(DASHBOARD), isVisible())
            .orComplainWith(StartError.class,
                    MESSAGE_FAILED_AUTHENTICATION));
}
 
Example #7
Source File: GoogleSearchResults.java    From tutorials with MIT License 6 votes vote down vote up
public List<String> answeredBy(Actor actor) {
    return Text.of(GoogleSearchPage.SEARCH_RESULT_TITLES).viewedBy(actor).asList();
}
 
Example #8
Source File: ApplicationDetails.java    From serenity-documentation with Apache License 2.0 6 votes vote down vote up
@Override
public ApplicationInformation answeredBy(Actor actor) {
    String title = BrowseTheWeb.as(actor).getTitle();
    String heading = Text.of(MAIN_HEADING).viewedBy(actor).value();
    String aboutInformation = Text.of(FOOTER).viewedBy(actor).value();

    return new ApplicationInformation(title, heading, aboutInformation);
}
 
Example #9
Source File: DisplayedItems.java    From serenity-documentation with Apache License 2.0 6 votes vote down vote up
@Override
public List<String> answeredBy(Actor actor) {
    return Text.of(ToDoList.TODO_ITEMS).viewedBy(actor).asList();
}
 
Example #10
Source File: CreateAFolder.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Override
@Step("{0} creates a '#name' folder")
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            Click.on(SidePanel.New_Item_Link),
            Choose.the(NewJobPage.Folder),
            Enter.theValue(name).into(NewJobPage.Item_Name_Field).thenHit(ENTER),
            Click.on(Save)
    );
}
 
Example #11
Source File: HaveAProjectCreated.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} creates the '#projectName' project")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            CreateAFreestyleProject.called(projectName).andConfigureItTo(requiredConfiguration),
            Click.on(SidePanel.Back_to_Dashboard)
    );
}
 
Example #12
Source File: HaveABuildMonitorViewCreated.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} creates a 'Build Monitor View' showing all the projects")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(CreateABuildMonitorView.called("Build Monitor").andConfigureItTo(
            DisplayAllProjects.usingARegularExpression()
    ));
}
 
Example #13
Source File: CreateAFreestyleProject.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Override
@Step("{0} creates a 'Freestyle Project' called '#name'")
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            CreateAProject.called(name)
                    .ofType(NewJobPage.Freestyle_Project)
                    .andConfigureItTo(this.configureTheProject)
    );
}
 
Example #14
Source File: ProjectWidgetInformation.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Override
public ProjectInformation answeredBy(Actor actor) {
    Target widget     = BuildMonitorDashboard.Project_Widget.of(projectName);
    String cssClasses = Attribute.of(widget).named("class").viewedBy(actor).asString();

    return new ProjectInformation(projectName, ProjectStatus.fromMultiple(cssClasses));
}
 
Example #15
Source File: ConfigureEmptyBuildMonitorView.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Override
@Step("{0} configures the Build Monitor View")
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            configureTheView,
            SaveTheChangesToBuildMonitor.andExitTheConfigurationScreen()
    );
}
 
Example #16
Source File: HaveAnExternalProjectCreated.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} creates the '#projectName' external project")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            CreateAnExternalProject.called(projectName),
            Click.on(Back_to_Dashboard)
    );
}
 
Example #17
Source File: AddProjects.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} decides to adds some projects to an empty Build Monitor")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            Click.on(BuildMonitorDashboard.Add_Some_Projects_link)
    );
}
 
Example #18
Source File: DefineABuildLogIndicatedFailureCause.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} defines what constitutes a problem with '#name'")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            DefineAFailureCause.called(name).describedAs(getOrElse(description, name)).indicatedBy(
                    LineInTheBuildLog.matching(regex)
            )
    );
}
 
Example #19
Source File: UseFailureCauseManagement.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} uses the 'Failure Cause Management'")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            Click.on(JenkinsHomePageWithBFA.Failure_Cause_Management_Link),
            defineFailureCauses,
            Click.on(Breadcrumbs.Jenkins_Link)
    );
}
 
Example #20
Source File: HaveAShellScriptFailureCauseDefined.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            UseFailureCauseManagement.to(
                    DefineABuildLogIndicatedFailureCause.called(name).
                            describedAs(description).
                            matching(Build_Log_Pattern)
            )
    );
}
 
Example #21
Source File: LineInTheBuildLog.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} defines a pattern indicating the failure cause")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            Click.on(FailureCauseManagementPage.Add_Indication),
            WaitUntil.the(FailureCauseManagementPage.Build_Log_Indication_Link, WebElementStateMatchers.isVisible()),
            Click.on(FailureCauseManagementPage.Build_Log_Indication_Link),
            Enter.theValue(pattern).into(FailureCauseManagementPage.Pattern_Field)
    );
}
 
Example #22
Source File: DefineAFailureCause.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            Click.on(FailureCauseManagementPage.Create_New_Link),
            Enter.theValue(name).into(FailureCauseManagementPage.Name),
            Enter.theValue(description).into(FailureCauseManagementPage.Description),
            configureFailureCauseIndicators,
            Click.on(FailureCauseManagementPage.Save)
    );
}
 
Example #23
Source File: SetBuildDescription.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} indicates that the build description should be set to '#description', based on regex '#regex')")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            AddABuildStep.called("Set build description"),
            Enter.theValue(regex).into(Setting.defining("Regular expression")),
            Enter.theValue(description).into(Setting.defining("Description"))
    );
}
 
Example #24
Source File: Claim.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} claims the last broken build of '#project' saying: '#reason'")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
        Click.on(Link.called(project)),
        Click.on(ProjectDetailsPage.Last_Failed_Build_Link),
        Click.on(ClaimableBuildDetailsPage.Claim_It_Link),
        Enter.theValue(reason).into(ClaimableBuildDetailsPage.Reason_Field),
        Click.on(ClaimableBuildDetailsPage.Claim_Button)
    );
}
 
Example #25
Source File: BrokenBuildClaiming.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} allows for a broken build to be claimed")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            AddAPostBuildAction.called("Allow broken build claiming")
    );
}
 
Example #26
Source File: HaveAFailingClaimableProjectCreated.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} creates the '#projectName' project and schedules a build that fails, but can be claimed")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            HaveAProjectCreated.called(projectName).andConfiguredTo(
                    ExecuteAShellScript.that(Finishes_With_Error),
                    BrokenBuildClaiming.allow()
            ),
            ScheduleABuild.of(projectName)
    );
}
 
Example #27
Source File: HaveASuccessfulProjectCreated.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} creates the '#projectName' project and schedules a build that passes")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            HaveAProjectCreated.called(projectName).andConfiguredTo(
                    ExecuteAShellScript.that(Finishes_With_Success)
            ),
            ScheduleABuild.of(projectName)
    );
}
 
Example #28
Source File: SetPipelineDefinition.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Step("{0} configures the Pipeline Defintion to execute '#pipelineDefintion'")
@Override
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            EnterCode.asFollows(pipelineDefintion).intoThePipelineEditor(PipelineDefinition.Editor)
    );
}
 
Example #29
Source File: BuyingAndSellingSharesStepDefinitions.java    From bdd-trader with Apache License 2.0 5 votes vote down vote up
@Given("(\\w+) (\\w+) is a registered trader$")
public void a_registered_trader(String firstName, String lastName) {

    Actor trader = OnStage.theActorCalled(firstName);

    trader.attemptsTo(
            RegisterWithBDDTrader.asANewClient(Client.withFirstName(firstName)
                                                     .andLastName(lastName)
                                                     .andEmail(firstName + "@" + lastName + ".com"))
    );
}
 
Example #30
Source File: CreateAPipelineProject.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
@Override
@Step("{0} creates a 'Pipeline Project' called '#name'")
public <T extends Actor> void performAs(T actor) {
    actor.attemptsTo(
            CreateAProject.called(name)
                    .ofType(NewJobPage.Pipeline)
                    .andConfigureItTo(this.configureTheProject)
    );
}