From aa6a2332cc4a920de181f5a26aa9b539f6381a93 Mon Sep 17 00:00:00 2001 From: Johan Brichau Date: Wed, 28 Feb 2024 19:37:58 +0100 Subject: [PATCH] Add some timeout helper methods --- .../instance/waitUntil.ifTimeout..st | 4 ++++ .../instance/waitUntil.ifTimeout.times100MsToWait..st | 9 +++++++++ .../instance/waitUntilNoBPNoSuchElementExceptionIn..st | 10 ++++++++++ .../Parasol-Core.package/monticello.meta/categories.st | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntil.ifTimeout..st create mode 100644 repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntil.ifTimeout.times100MsToWait..st create mode 100644 repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntilNoBPNoSuchElementExceptionIn..st diff --git a/repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntil.ifTimeout..st b/repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntil.ifTimeout..st new file mode 100644 index 0000000..b8ef20c --- /dev/null +++ b/repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntil.ifTimeout..st @@ -0,0 +1,4 @@ +misc. +waitUntil: aCondition ifTimeout: timeoutBlock + + ^ self waitUntil: aCondition ifTimeout: timeoutBlock times100MsToWait: 50 \ No newline at end of file diff --git a/repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntil.ifTimeout.times100MsToWait..st b/repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntil.ifTimeout.times100MsToWait..st new file mode 100644 index 0000000..acbeca2 --- /dev/null +++ b/repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntil.ifTimeout.times100MsToWait..st @@ -0,0 +1,9 @@ +misc. +waitUntil: aCondition ifTimeout: timeoutBlock times100MsToWait: times + + | delay100ms | + delay100ms := Delay forMilliseconds: 100. + times timesRepeat: [ + aCondition value ifTrue: [ ^ true ] + ifFalse: [ delay100ms wait ] ]. + ^ timeoutBlock value \ No newline at end of file diff --git a/repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntilNoBPNoSuchElementExceptionIn..st b/repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntilNoBPNoSuchElementExceptionIn..st new file mode 100644 index 0000000..43b9e36 --- /dev/null +++ b/repository/Parasol-Core.package/BPWebDriverTestCase.class/instance/waitUntilNoBPNoSuchElementExceptionIn..st @@ -0,0 +1,10 @@ +misc. +waitUntilNoBPNoSuchElementExceptionIn: aBlock + + | delay100ms | + delay100ms := Delay forMilliseconds: 100. + 30 timesRepeat: [ + [ ^ aBlock value ] + on: BPNoSuchElementException + do: [ :exc | delay100ms wait ] ]. + ^ self error: 'Timeout waiting for element to be available' \ No newline at end of file diff --git a/repository/Parasol-Core.package/monticello.meta/categories.st b/repository/Parasol-Core.package/monticello.meta/categories.st index 3cb6ad3..ff190a1 100644 --- a/repository/Parasol-Core.package/monticello.meta/categories.st +++ b/repository/Parasol-Core.package/monticello.meta/categories.st @@ -1 +1 @@ -SystemOrganization addCategory: #'Parasol-Core'! +self packageOrganizer ensurePackage: #'Parasol-Core' withTags: #()!