package com.sdl.selenium.extjs6.panel;

import com.sdl.selenium.web.SearchType;
import com.sdl.selenium.web.WebLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Panel extends WebLocator {
    private static final Logger LOGGER = LoggerFactory.getLogger(Panel.class);

    public Panel() {
        withClassName("Panel");
        withBaseCls("x-panel");
        WebLocator header = new WebLocator().withClasses("x-title").withRoot("//");
        withTemplateTitle(new WebLocator(header));
    }

    public Panel(WebLocator container) {
        this();
        withContainer(container);
    }

    public Panel(WebLocator container, String title) {
        this(container);
        withTitle(title, SearchType.EQUALS);
    }

    private WebLocator getCollapseEl(String type) {
        return new WebLocator(this).setClasses("x-tool-" + type);
    }

    public boolean collapse() {
        return !getCollapseEl("collapse").isElementPresent() || getCollapseEl("collapse").click();
    }

    public boolean expand() {
        return !getCollapseEl("expand").isElementPresent() || getCollapseEl("expand").click();
    }

    @Override
    public Panel withVisibility(boolean visible) {
        if (visible) {
            this.withExcludeClasses("x-collapsed ", "x-panel-collapsed");
        } else {
            this.withClasses("x-collapsed ", "x-panel-collapsed");
        }
        return this;
    }
}

@@ -839,25 +839,46 @@
 his).set
-Classes(%22
+ElPath(%22//*%5Bcontains(@class, '
 x-tool-%22
@@ -884,16 +884,24 @@
 %22 + type
+ + %22')%5D%22
 );%0A    %7D

revert getCollapseEl