Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selenium Step Extensions #409

Open
StefanFellinger opened this issue May 20, 2022 · 2 comments
Open

Selenium Step Extensions #409

StefanFellinger opened this issue May 20, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@StefanFellinger
Copy link

With my workaround in #407 i've added other functionality too. I want to share with you:

  • User clears text on -> see Selenium Input Step Extension #408
  • should display table having data (i'm using the approach that each row id is build by column property + row Index). I've added my code snippet below:
 // a list of row maps where each map entry identifies one column. The key of the map is
        // from the header column
        final List<Map<String, String>> dataMatrix = dataTable.asMaps();
        final List<TestAction> elementActions = new ArrayList<>();
        for (int i = 0; i < dataMatrix.size(); i++) {
            final Map<String, String> valueByColumnId = dataMatrix.get(i);
            for (final Map.Entry<String, String> columnEntry : valueByColumnId.entrySet()) {
                final String columnId = columnEntry.getKey() + i;
                final String expectedText = columnEntry.getValue();
                final FindElementAction.Builder elementAction = SeleniumActionBuilder.selenium().browser(
                        browser()).find().element("id", columnId).displayed(
                        StringUtils.hasText(expectedText)).text(expectedText);
                elementActions.add(EchoAction.Builder.echo(
                        String.format("should display table column with id = %s having value %s", columnId,
                                      expectedText)).build());
                elementActions.add(RepeatOnErrorUntilTrueTemplate.builder()
                                           .indexName(columnId)
                                           .maxRepeats(maxRepeatsOnError)
                                           .autoSleep(autoSleep)
                                           .action(elementAction)
                                           .build());
            }
        }
        runner.run(Sequence.Builder.sequential().actions(elementActions.toArray(new TestAction[0])));
@christophd
Copy link
Member

Thanks! So do I get this right that with your new step users should be able to provide an expected table content and the step automatically compares/verifies each row and column?

@christophd christophd added the enhancement New feature or request label May 30, 2022
@StefanFellinger
Copy link
Author

StefanFellinger commented May 30, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants