yaks icon indicating copy to clipboard operation
yaks copied to clipboard

Selenium Step Extensions

Open StefanFellinger opened this issue 3 years ago • 2 comments

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

  • User clears text on -> see #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])));

StefanFellinger avatar May 20 '22 10:05 StefanFellinger

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 avatar May 30 '22 08:05 christophd

Thats right, if they apply ids per column and row following the format "some column name" + row Index.

Christoph Deppisch @.***> schrieb am Mo., 30. Mai 2022, 10:41:

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?

— Reply to this email directly, view it on GitHub https://github.com/citrusframework/yaks/issues/409#issuecomment-1140873181, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMAAQKKLLH6CAZQNTCOUUTVMR5KNANCNFSM5WPBKTMA . You are receiving this because you authored the thread.Message ID: @.***>

StefanFellinger avatar May 30 '22 13:05 StefanFellinger