citrusframework / yaks

YAKS is a platform to enable Cloud Native BDD testing on Kubernetes
Apache License 2.0
82 stars 28 forks source link

Feature Request: Retry Logic for Selenium Steps #407

Open StefanFellinger opened 2 years ago

StefanFellinger commented 2 years ago

It would be nice to have a retry logic for SeleniumSteps. We've implemented our own Workaround like so:

runner.run(RepeatOnErrorUntilTrueTemplate.builder() .indexName(indexName) .maxRepeats(maxRepeatsOnError) .autoSleep(autoSleep) .actions(Arrays.asList(actionBuilders)) .build());

We've also added an own wrapper for RepeatOnErrorUntilTrue using the Catch Action too. This was necessary since SeleniumSteps may throw Selenium exceptions, but RepeatOnErrorUntilTrue only catches the CitrusRuntimeException. By using the CatchAction without expected exception list we get the desired behaviour since the CatchAction will throw our required CitrusRuntimeException in that case.

Kind regards,

Stefan

christophd commented 2 years ago

Awesome thanks!

I guess this is only for a subset of Selenium actions, isn't it? Could you please share a list of actions/steps where you think the retry logic makes sense?

StefanFellinger commented 2 years ago

We've added it for each step since a previous selenium step may be ongoing on some selenium node.

christophd commented 2 years ago

We could introduce a common retry attempt setting just like JDBC steps are doing (https://github.com/citrusframework/yaks/blob/main/java/steps/yaks-jdbc/src/main/java/org/citrusframework/yaks/jdbc/JdbcSettings.java) so users can enable/disable retry with these settings:

Given Selenium max retry attempts: 10
Given Selenium retry delay: 500ms

Also a env setting is available to set the retry globally:

YAKS_SELENIUM_MAX_RETRY_ATTEMPTS=10 YAKS_SELENIUM_DELAY_BETWEEN_RETRY_ATTEMPTS=1000

I would vote for having retry logic disabled by default (YAKS_SELENIUM_MAX_RETRY_ATTEMPTS=0)

StefanFellinger commented 2 years ago

That would be fine for Our use case. Our Observation Was That e.g clicking a Button and validating a second Element than requires a retry since most Browser interactions are slower than our steps execution

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

We could introduce a common retry attempt setting just like JDBC steps are doing ( https://github.com/citrusframework/yaks/blob/main/java/steps/yaks-jdbc/src/main/java/org/citrusframework/yaks/jdbc/JdbcSettings.java) so users can enable/disable retry with these settings:

Given Selenium max retry attempts: 10Given Selenium retry delay: 500ms

Also a env setting is available to set the retry globally:

YAKS_SELENIUM_MAX_RETRY_ATTEMPTS=10 YAKS_SELENIUM_DELAY_BETWEEN_RETRY_ATTEMPTS=1000

I would vote for having retry logic disabled by default (YAKS_SELENIUM_MAX_RETRY_ATTEMPTS=0)

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