Skip to content

Commit fff80f3

Browse files
committed
Support also string NONE in run on failure disabling
1 parent 130bd3f commit fff80f3

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

atest/acceptance/keywords/run_on_failure.robot

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,29 @@ Log Title On Failure
2626
... ${FAILURE MESSAGE}
2727
... Page Should Not Contain needle loglevel=None
2828

29-
Disable Run on Failure
29+
Disable Run on Failure With Nothing
3030
[Documentation]
3131
... LOG 1 No keyword will be run on failure.
3232
... LOG 2.1:2 NONE
33-
... LOG 3 No keyword will be run on failure.
34-
... LOG 4.1:2 NONE
35-
Register Keyword to Run On Failure Nothing
33+
SeleniumLibrary.Register Keyword to Run On Failure Nothing
3634
Run Keyword And Expect Error
3735
... ${FAILURE MESSAGE}
3836
... Page Should Not Contain needle loglevel=None
39-
Register Keyword to Run On Failure ${NONE}
37+
38+
Disable Run on Failure With Python None
39+
[Documentation]
40+
... LOG 1 No keyword will be run on failure.
41+
... LOG 2.1:2 NONE
42+
SeleniumLibrary.Register Keyword to Run On Failure ${NONE}
43+
Run Keyword And Expect Error
44+
... ${FAILURE MESSAGE}
45+
... Page Should Not Contain needle loglevel=None
46+
47+
Disable Run on Failure With String NONE
48+
[Documentation]
49+
... LOG 1 No keyword will be run on failure.
50+
... LOG 2.1:2 NONE
51+
SeleniumLibrary.Register Keyword to Run On Failure NONE
4052
Run Keyword And Expect Error
4153
... ${FAILURE MESSAGE}
4254
... Page Should Not Contain needle loglevel=None

src/SeleniumLibrary/keywords/runonfailure.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
from typing import Optional
1617

1718
from SeleniumLibrary.base import LibraryComponent, keyword
1819

1920

2021
class RunOnFailureKeywords(LibraryComponent):
2122
@keyword
22-
def register_keyword_to_run_on_failure(self, keyword: str) -> str:
23+
def register_keyword_to_run_on_failure(self, keyword: Optional[str]) -> str:
2324
"""Sets the keyword to execute, when a SeleniumLibrary keyword fails.
2425
2526
``keyword`` is the name of a keyword that will be executed if a
@@ -61,6 +62,8 @@ def register_keyword_to_run_on_failure(self, keyword: str) -> str:
6162

6263
@staticmethod
6364
def resolve_keyword(name):
64-
if name is None or isinstance(name, str) and name.upper() == "NOTHING":
65+
if name is None:
66+
return None
67+
if isinstance(name, str) and name.upper() == "NOTHING" or name.upper() == "NONE":
6568
return None
6669
return name

0 commit comments

Comments
 (0)