// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/action/JSClick.java
// public class JSClick implements Action {
// 
//     private final Target target;
// 
//     public JSClick(Target target) {
//         this.target = target;
//     }
// 
//     @Override
//     @Step("{0} clicks on #target")
//     public <T extends Actor> void performAs(T theActor) {
//         WebElement targetElement = target.resolveFor(theActor);
//         BrowseTheWeb.as(theActor).evaluateJavascript("arguments[0].click()", targetElement);
//     }
// 
//     public static Action on(Target target) {
//         return instrumented(JSClick.class, target);
//     }
// 
//     private String pathTo(Target target) {
//         return target.getCssOrXPathSelector();
//     }
// }
// 
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/pages/todolist/items/TodoListItem.java
// public class TodoListItem {
// 
//     public static Target COMPLETE_ITEM_BUTTON = Target.the("Complete button")
//             .locatedBy( "//*[@class='view' and contains(.,'{0}')]//input[@type='checkbox']");
// 
//     public static Target DELETE_ITEM_BUTTON = Target.the("Delete button")
//             .locatedBy( "//*[@class='view' and contains(.,'{0}')]//button[@class='destroy']");
// 
//     public static Target ITEM_TEXT_LABEL = Target.the("Item text label")
//             .locatedBy("//*[@class='view' and contains(.,'{0}')]//label");
// 
//     public static Target ITEM_TEXT_INPUT = Target.the("Item text label")
//             .locatedBy("//li[contains(.,'{0}')]//form/input");
// }


import net.serenitybdd.demos.todos.action.JSClick;
import net.serenitybdd.demos.todos.pages.todolist.items.TodoListItem;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Task;
import net.serenitybdd.screenplay.targets.Target;
import net.thucydides.core.annotations.Step;
import static net.serenitybdd.screenplay.Tasks.instrumented;
package net.serenitybdd.demos.todos.tasks;



public class DeleteAnItem implements Task {

    private final String itemName;

    protected DeleteAnItem(String itemName) {
        this.itemName = itemName;
    }

    @Step("{0} deletes the item '#itemName'")
    public <T extends Actor> void performAs(T theActor) {
        Target deleteButton = TodoListItem.DELETE_ITEM_BUTTON.of(itemName);
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/action/JSClick.java
// public class JSClick implements Action {
// 
//     private final Target target;
// 
//     public JSClick(Target target) {
//         this.target = target;
//     }
// 
//     @Override
//     @Step("{0} clicks on #target")
//     public <T extends Actor> void performAs(T theActor) {
//         WebElement targetElement = target.resolveFor(theActor);
//         BrowseTheWeb.as(theActor).evaluateJavascript("arguments[0].click()", targetElement);
//     }
// 
//     public static Action on(Target target) {
//         return instrumented(JSClick.class, target);
//     }
// 
//     private String pathTo(Target target) {
//         return target.getCssOrXPathSelector();
//     }
// }
// 
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/pages/todolist/items/TodoListItem.java
// public class TodoListItem {
// 
//     public static Target COMPLETE_ITEM_BUTTON = Target.the("Complete button")
//             .locatedBy( "//*[@class='view' and contains(.,'{0}')]//input[@type='checkbox']");
// 
//     public static Target DELETE_ITEM_BUTTON = Target.the("Delete button")
//             .locatedBy( "//*[@class='view' and contains(.,'{0}')]//button[@class='destroy']");
// 
//     public static Target ITEM_TEXT_LABEL = Target.the("Item text label")
//             .locatedBy("//*[@class='view' and contains(.,'{0}')]//label");
// 
//     public static Target ITEM_TEXT_INPUT = Target.the("Item text label")
//             .locatedBy("//li[contains(.,'{0}')]//form/input");
// }


// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/tasks/DeleteAnItem.java
import net.serenitybdd.demos.todos.action.JSClick;
import net.serenitybdd.demos.todos.pages.todolist.items.TodoListItem;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Task;
import net.serenitybdd.screenplay.targets.Target;
import net.thucydides.core.annotations.Step;
import static net.serenitybdd.screenplay.Tasks.instrumented;

package net.serenitybdd.demos.todos.tasks;



public class DeleteAnItem implements Task {

    private final String itemName;

    protected DeleteAnItem(String itemName) {
        this.itemName = itemName;
    }

    @Step("{0} deletes the item '#itemName'")
    public <T extends Actor> void performAs(T theActor) {
        Target deleteButton = TodoListItem.DELETE_ITEM_BUTTON.of(itemName);
        theActor.attemptsTo(JSClick.on(deleteButton));