package ru.otus.mobile.component;

import com.codeborne.selenide.SelenideElement;
import com.google.inject.Inject;
import io.appium.java_client.AppiumBy;

import static com.codeborne.selenide.appium.SelenideAppium.$;

public final class WishlistFormComponent extends BaseMobileComponent {
    private final SelenideElement titleInput;
    private final SelenideElement saveButton;

    @Inject
    public WishlistFormComponent() {
        this($(AppiumBy.id("android:id/content")));
    }

    public WishlistFormComponent(SelenideElement root) {
        super(root);
        this.titleInput = byIdInRoot("title_input");
        this.saveButton = byIdInRoot("save_button");
    }

    public void save(String title) {
        titleInput.click();
        titleInput.clear();
        titleInput.sendKeys(title);
        saveButton.click();
    }
}
