LDAP Fixes

This fix includes:
    - Wait for LDAP checkbox to get available
    - Disable LDAP configuration via Redfish before enabling it using GUI
    - Remove check for non-secure LDAP

Change-Id: I314eca8c5b692942e6b3870b443da43fb06d5c60
Signed-off-by: Sweta Potthuri <spotthur@in.ibm.com>
diff --git a/gui/gui_test/security_and_access_menu/test_ldap_sub_menu.robot b/gui/gui_test/security_and_access_menu/test_ldap_sub_menu.robot
index d8ec11d..444da2b 100644
--- a/gui/gui_test/security_and_access_menu/test_ldap_sub_menu.robot
+++ b/gui/gui_test/security_and_access_menu/test_ldap_sub_menu.robot
@@ -12,7 +12,7 @@
 *** Variables ***
 
 ${xpath_ldap_heading}                   //h1[text()="LDAP"]
-${xpath_enable_ldap_checkbox}           //*[@data-test-id='ldap-checkbox-ldapAuthenticationEnabled']
+${xpath_enable_ldap_checkbox}           //*[@data-test-id='ldap-checkbox-ldapAuthenticationEnabled']//following-sibling::label
 ${xpath_secure_ldap_checkbox}           //*[@data-test-id='ldap-checkbox-secureLdapEnabled']
 ${xpath_service_radio_button}           //*[@data-test-id="ldap-radio-activeDirectoryEnabled"]
 ${xpath_add_role_group_button}          //button[contains(text(),'Add role group')]
@@ -176,7 +176,7 @@
     Click Element  ${xpath_secuity_and_accesss_menu}
     Click Element  ${xpath_ldap_sub_menu}
     Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  ldap
-    Element Should Be Enabled   ${xpath_enable_ldap_checkbox}
+    Wait Until Element Is Enabled  ${xpath_enable_ldap_checkbox}  timeout=10s
 
     Valid Value  LDAP_TYPE  valid_values=["ActiveDirectory", "LDAP"]
     Valid Value  LDAP_USER
@@ -203,9 +203,15 @@
     # ldap_bind_dn_password  The LDAP bind distinguished name password.
     # ldap_base_dn           The LDAP base distinguished name.
 
-    Select Checkbox  ${xpath_enable_ldap_checkbox}
-    Checkbox Should Be Selected  ${xpath_enable_ldap_checkbox}
-    ${radio_buttons}=    Get WebElements    ${xpath_service_radio_button}
+    # Clearing existing LDAP configuration by disabling it.
+    Redfish.Patch  ${REDFISH_BASE_URI}AccountService
+    ...  body={'${LDAP_TYPE}': {'ServiceEnabled': ${False}}}
+
+    # Wait for GUI to reflect LDAP disabled status.
+    Run Keywords  Refresh GUI  AND  Sleep  10s
+
+    Click Element  ${xpath_enable_ldap_checkbox}
+    ${radio_buttons}=  Get WebElements  ${xpath_service_radio_button}
 
     Run Keyword If  '${ldap_service_type}' == 'LDAP'
     ...  Click Element At Coordinates  ${radio_buttons}[${0}]  0  0
@@ -214,7 +220,6 @@
     Wait Until Page Contains Element  ${xpath_ldap_url}
     Run Keyword If  '${ldap_mode}' == 'secure'
     ...   Click Element At Coordinates  ${xpath_secure_ldap_checkbox}  0  0
-    ...  ELSE  Unselect Checkbox  ${xpath_secure_ldap_checkbox}
 
     Input Text  ${xpath_ldap_url}  ${ldap_server_uri}
     Input Text  ${xpath_ldap_bind_dn}  ${ldap_bind_dn}