{{#if copyright.claimant}}
    /*
    All the code that follow is
    Copyright (c) {{copyright.year}}, {{copyright.claimant}}. All Rights Reserved.
    Not for reuse without permission.
    */

{{/if}}
{{#if model.namespace}}package {{model.namespace}};
{{/if}}
import { sendKeys, click } from "../browser_utilities";
import { compareVisual, masking } from "../visual_utilities/visualHelper";
import BasePage from "./basePage";

export class {{model.name}} extends BasePage {
    constructor(){
        super();
        {{#attributes}}    {{#if attribute.strategy}}
            this.{{attribute.name}} = element{{#equals type 'radio'}}.all{{/equals}}( By.{{attribute.strategy}}("{{{attribute.value}}}"));{{/if}}{{/attributes}}
    }
{{#operations}}
        /**
        * {{#if argument}}{{argument.documentation}}{{else}}{{operation.documentation}}{{/if}}
        *
        * @return the {{default target.modelName @root.model.name}} class instance.
        */
        async {{operation.name}}() {
    {{#if argument}}
        {{#unequals type 'radio'}}
                return {{operation.name}}(data.get("{{argument.key}}"));
                }

                /**
                * {{operation.documentation}}
                *
                */
                async {{operation.name}}(String {{argument.name}}) {
        {{/unequals}}
    {{/if}}
    {{#equals type 'button'}}
        click(this.{{attribute.name}});
    {{/equals}}
    {{#equals type 'checkbox'}}
            if ({{#unless negate}}!{{/unless}}{{attribute.name}}.isSelected()) {
        click(this.{{attribute.name}});
            }
    {{/equals}}
    {{#equals type 'fill'}}
        {{#fill}}
            {{operation.name}}();
        {{/fill}}
    {{/equals}}
    {{#equals type 'fill.submit'}}
            fill();
            return submit();
    {{/equals}}
    {{#equals type 'link'}}
        click(this.{{attribute.name}});
    {{/equals}}
    {{#equals type 'radio'}}
            for (WebElement el : {{attribute.name}}) {
            if (el.getAttribute("value").equals({{argument.name}})) {
            if (!el.isSelected()) {
            el.click();
            }
            break;
            }
            }
    {{/equals}}
    {{#equals type 'select'}}
            new Select({{attribute.name}}).{{#if negate}}de{{/if}}selectByVisibleText({{argument.name}});
    {{/equals}}
    {{#equals type 'submit'}}
        {{target.name}}();
        {{#if target.modelName}}
            {{target.modelName}} target = new {{target.modelName}}(driver, data, timeout);
                PageFactory.initElements(driver, target);
        {{/if}}
    {{/equals}}
    {{#equals type 'text'}}
        {{attribute.name}}.sendKeys({{argument.name}});
    {{/equals}}
    {{#equals type 'verify.loaded'}}
            (new WebDriverWait(driver, timeout)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
            return d.getPageSource().contains({{attribute.name}});
            }
            });
    {{/equals}}
    {{#equals type 'verify.url'}}
            (new WebDriverWait(driver, timeout)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
            return d.getCurrentUrl().contains({{attribute.name}});
            }
            });
    {{/equals}}
        }
{{/operations}}
    }
