Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

CreatePageWizardImpl uses labels to find buttons, which will not work if the UI has a different language #465

Open
henrykuijpers opened this issue Nov 11, 2020 · 3 comments

Comments

@henrykuijpers
Copy link

henrykuijpers commented Nov 11, 2020

In CreatePageWizardImpl, there are 3 button labels ("Next", "Create" and "Done"), which are used to find certain buttons in the Create Page Wizard.

However, these button labels are in English and our project is in Dutch, so we are unable to find those buttons and therefore the code is failing to execute.

It is unacceptable for us to translate the buttons back to English.

I would suggest to find a better way to find these buttons and click them. Or, but I think that's a worse solution, make the button text configurable in some way.

@henrykuijpers
Copy link
Author

henrykuijpers commented Nov 11, 2020

I suggest the following implementation, replacing the one that is present now:

/**
 * Default Bobcat implementation of {@link CreatePageWizard} for AEM 6.4
 */
@PageObject(css = "form.cq-siteadmin-admin-createpage")
public class CreatePageWizardImpl implements CreatePageWizard {
    @FindBy(css = "[type=submit][data-foundation-wizard-control-action=next]")
    private WebElement createButton;

    @FindBy(css = "[type=button][data-foundation-wizard-control-action=next]")
    private WebElement nextButton;

    @FindPageObject
    private TemplateList templateList;

    @Global
    @FindPageObject
    private CreatePageProperties createPageProperties;

    @Global
    @FindBy(css = ".coral3-Dialog-wrapper")
    private WebElement pageCreatedModal;

    @Inject
    protected BobcatWait wait;

    @Override
    @Step("Select template {templateName}")
    public CreatePageWizard selectTemplate(String templateName) {
        templateList.selectTemplate(templateName);
        nextButton.click();
        return this;
    }

    @Override
    @Step("Provide name {name}")
    public CreatePageWizard provideName(String name) {
        createPageProperties.getNameTextField().sendKeys(name);
        return this;
    }

    @Override
    @Step("Provide title {title}")
    public CreatePageWizard provideTitle(String title) {
        createPageProperties.getTitleTextField().sendKeys(title);
        return this;
    }

    @Override
    @Step("Submit page for creation")
    public void submit() {
        wait.until(input -> createButton.isEnabled());
        createButton.click();
        List<WebElement> elements =
                pageCreatedModal.findElements(By.cssSelector(".coral3-Dialog--success [variant='secondary']"));

        elements.stream()
                .findFirst()
                .orElseThrow(() -> new NoSuchElementException("\"Done\" button not found"))
                .click();
    }
}

@henrykuijpers
Copy link
Author

Any thoughts @mkrzyzanowski ?

@henrykuijpers
Copy link
Author

@mkrzyzanowski ping

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant