From 7cfa8c67fc51f4fad6a5f936b5a614840764b1c9 Mon Sep 17 00:00:00 2001 From: hildamoni Date: Tue, 2 Feb 2021 13:57:32 -0500 Subject: [PATCH 1/2] - Adding an optional option not to clear the text --- .../Web/Selenium/BuiltInFunctions.py | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py b/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py index 1ad42d30b..d74053c64 100644 --- a/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py +++ b/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py @@ -545,6 +545,7 @@ def Enter_Text_In_Text_Box(step_data): text_value = "" use_js = False without_click = False + clear=True #by default it will clear the text field. If a user profile optional option with clear False. It will no clear global selenium_driver Element = LocateElement.Get_Element(step_data, selenium_driver) @@ -558,6 +559,8 @@ def Enter_Text_In_Text_Box(step_data): delay = float(right.strip()) elif "use js" in left: use_js = right.strip().lower() in ("true", "yes", "1") + elif "clear" in left: + clear= False if use_js: try: @@ -576,7 +579,8 @@ def Enter_Text_In_Text_Box(step_data): # Soemtimes text field becomes unclickable after entering text? selenium_driver.execute_script("arguments[0].click();", Element) - else: + + elif clear==True: #By default clear the text field try: Element.click() except: @@ -596,16 +600,18 @@ def Enter_Text_In_Text_Box(step_data): Element.clear() #some cases it works .. so adding it here just incase except: True - if delay == 0: - Element.send_keys(text_value) - else: - for c in text_value: - Element.send_keys(c) - time.sleep(delay) - try: - Element.click() - except: # sometimes text field can be unclickable after entering text - pass + + + if delay == 0: + Element.send_keys(text_value) + else: + for c in text_value: + Element.send_keys(c) + time.sleep(delay) + try: + Element.click() + except: # sometimes text field can be unclickable after entering text + pass # CommonUtil.TakeScreenShot(sModuleInfo) CommonUtil.ExecLog( From a270d8cc31ffb87ae476d015071f11fcd54e3910 Mon Sep 17 00:00:00 2001 From: hildamoni Date: Tue, 2 Feb 2021 14:04:23 -0500 Subject: [PATCH 2/2] correct spelling errors --- .../Built_In_Automation/Web/Selenium/BuiltInFunctions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py b/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py index d74053c64..33cddfb20 100644 --- a/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py +++ b/Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py @@ -545,7 +545,7 @@ def Enter_Text_In_Text_Box(step_data): text_value = "" use_js = False without_click = False - clear=True #by default it will clear the text field. If a user profile optional option with clear False. It will no clear + clear=True #by default it will clear the text field. If a user provides optional option with clear = False. It will not clear global selenium_driver Element = LocateElement.Get_Element(step_data, selenium_driver) @@ -577,7 +577,7 @@ def Enter_Text_In_Text_Box(step_data): f"arguments[0].value = `{text_value}`;", Element ) - # Soemtimes text field becomes unclickable after entering text? + # Sometimes text field becomes unclickable after entering text? selenium_driver.execute_script("arguments[0].click();", Element) elif clear==True: #By default clear the text field