Open mikahanninen opened 2 years ago
Would a fix like this be acceptable?
diff --git a/src/SeleniumLibrary/keywords/formelement.py b/src/SeleniumLibrary/keywords/formelement.pyindex 15ef612..ed38285 100644
--- a/src/SeleniumLibrary/keywords/formelement.py
+++ b/src/SeleniumLibrary/keywords/formelement.py
@@ -17,7 +17,7 @@
import os
from typing import Optional, Union
-from robot.libraries.BuiltIn import BuiltIn
+from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
from selenium.webdriver.remote.webelement import WebElement
from SeleniumLibrary.base import LibraryComponent, keyword
@@ -504,11 +504,17 @@ class FormElementKeywords(LibraryComponent):
element = self.find_element(locator)
if clear:
element.clear()
+
if disable_log:
- self.info("Temporally setting log level to: NONE")
- previous_level = BuiltIn().set_log_level("NONE")
+ try:
+ self.info("Temporally setting log level to: NONE")
+ previous_level = BuiltIn().set_log_level("NONE")
+ except RobotNotRunningError:
+ self.info('RF log levels not available when RF is not running.')
+
try:
element.send_keys(text)
finally:
- if disable_log:
+ if disable_log and 'previous_level' in locals():
BuiltIn().set_log_level(previous_level)
That looks good, although I'd avoid the black-magick of 'previous_level' in locals()
(and check for previous_level
against None
if the call of set_log_level()
will return just strings).
Any intention to open a PR with the change solving this issue?
For issues
Steps to reproduce the issue
Error messages and additional information
Expected behavior and actual behavior
Keyword
Input Password
works with and without Robot FrameworkEnvironment
Browser: default by Open Browser keyword Browser driver: Gecko Operating System: Windows 10 Libraries