<commit_before>package com.sdl.selenium.extjs6.form;

import com.sdl.selenium.web.WebLocator;

public class FieldSet extends WebLocator {

    public FieldSet() {
        setClassName("FieldSet");
        setBaseCls("x-fieldset");
        setTag("fieldset");
        setExcludeClasses("x-hide-display", "x-masked");
        setTemplate("text", "count(.//*[normalize-space(.)=%s]) > 0");
    }

    public FieldSet(WebLocator container) {
        this();
        setContainer(container);
    }

    public FieldSet(WebLocator container, String text) {
        this(container);
        setText(text);
    }

    public boolean isCollapsed() {
        String cls = getAttributeClass();
        return cls != null && cls.contains("x-fieldset-collapsed");
    }

    public boolean expand() {
        WebLocator legendElement = new WebLocator(this).setText(getPathBuilder().getText());
        return !isCollapsed() || legendElement.click();
    }

    public boolean collapse() {
        WebLocator legendElement = new WebLocator(this).setText(getPathBuilder().getText());
        return isCollapsed() || legendElement.click();
    }
}<commit_msg>improvement expand method from FieldSet<commit_after>package com.sdl.selenium.extjs6.form;

import com.sdl.selenium.web.WebLocator;

public class FieldSet extends WebLocator {

    public FieldSet() {
        setClassName("FieldSet");
        setBaseCls("x-fieldset");
        setTag("fieldset");
        setExcludeClasses("x-hide-display", "x-masked");
        setTemplate("text", "count(.//*[normalize-space(.)=%s]) > 0");
    }

    public FieldSet(WebLocator container) {
        this();
        setContainer(container);
    }

    public FieldSet(WebLocator container, String text) {
        this(container);
        setText(text);
    }

    public boolean isCollapsed() {
        String cls = getAttributeClass();
        return cls != null && cls.contains("x-fieldset-collapsed");
    }

    public boolean expand() {
        return !isCollapsed() || getExpandEl().click();
    }

    public boolean collapse() {
        return isCollapsed() || getExpandEl().click();
    }

    private WebLocator getExpandEl() {
        return new WebLocator(this).setClasses("x-fieldset-header-text").setText(getPathBuilder().getText());
    }
}
{'fraction_non_alphanumeric': 0.1406660823838738, 'fraction_numerical': 0.0017528483786152498, 'mean_word_length': 2.9773519163763065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '133973', 'n_tokens_mistral': 682, 'n_tokens_neox': 655, 'n_words': 124}