Fixing xpaths of elements used to filter and select events in server health

Change-Id: I0479063de506102cb3335c08e93d05aa79593de7
Signed-off-by: Anusha Dathatri <adathatr@in.ibm.com>
diff --git a/gui/data/resource_variables.py b/gui/data/resource_variables.py
index f99070d..fb1541f 100644
--- a/gui/data/resource_variables.py
+++ b/gui/data/resource_variables.py
@@ -97,11 +97,9 @@
     xpath_refresh_circle = "/html/body/main/loader/div[1]/svg/circle"
     xpath_drop_down_timezone_utc =  \
         "//*[@id='event-log']/section[1]/div/div/ul/li[2]/button"
-    xpath_event_filter_all = "//*[@id='event-filter']/div[3]/div/button"
-    xpath_event_filter_resolved =  \
-        "//*[@id='event-filter']/div[3]/div/ul/li[2]/button"
-    xpath_event_filter_unresolved = \
-        "//*[@id='event-filter']/div[3]/div/ul/li[3]/button"
+    xpath_event_filter_all = "//*[text()='All events']"
+    xpath_event_filter_resolved = "//*[text()='Resolved events']"
+    xpath_event_filter_unresolved = "//*[text()='Unresolved events']"
     xpath_event_action_bars = \
         "//*[@id='event__actions-bar']/div[1]/label/span"
     xpath_event_action_delete = \
@@ -117,15 +115,12 @@
         "//*[@id='event__actions-bar']/div[2]/div[1]/div[2]/button[2]"
     xpath_event_delete_yes = \
         "//*[@id='event__actions-bar']/div[2]/div[1]/div[2]/button[1]"
-    xpath_individual_event_select = \
-        "//*[@id='event-log__events']/log-event[1]/div/div[1]/div[2]/label/" +\
-        "span"
+    xpath_individual_event_select = "(//*[@class='control__indicator'])[2]"
     xpath_individual_event_delete = \
         "//*[@id='event__actions-bar']/div[2]/div[2]/button[1]"
-    xpath_second_event_select = \
-        "//*[@id='event-log__events']/log-event[2]/div/div[1]/div[2]/label/" +\
-        "span"
+    xpath_second_event_select = "(//*[@class='control__indicator'])[3]"
     xpath_individual_event_resolved = \
         "//*[@id='event__actions-bar']/div[2]/div[2]/button[2]"
     xpath_individual_event_export = \
         "//*[@id='event__actions-bar']/div[2]/div[2]/a"
+    xpath_select_all_events = "(//*[@class='control__indicator'])[1]"
diff --git a/gui/test/gui_header/test_obmc_gui_server_health.robot b/gui/test/gui_header/test_obmc_gui_server_health.robot
index 88fdd69..5c8973a 100644
--- a/gui/test/gui_header/test_obmc_gui_server_health.robot
+++ b/gui/test/gui_header/test_obmc_gui_server_health.robot
@@ -81,7 +81,7 @@
     Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
     Wait Until Element is Visible  //*[@class='dropdown__wrapper']
     Click Element  //*[@class='dropdown__wrapper']
-    Page Should Contain Element  ${xpath_event_filter_all}  limit=1
+    Page Should Contain Element  ${xpath_event_filter_all}  limit=2
     Page Should Contain Element  ${xpath_event_filter_resolved}  limit=1
     Page Should Contain Element  ${xpath_event_filter_unresolved}  limit=1
 
@@ -93,7 +93,7 @@
     # Ensure that page is not in refreshing state.
     Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
     Page Should Contain Element  ${xpath_event_action_bars}  limit=1
-    Page Should Contain Element  //*[@class='control__indicator']
+    Page Should Contain Element  ${xpath_select_all_events}
 
 
 Verify Click Events Check Box
@@ -102,9 +102,11 @@
     ...  element.
     [Tags]  Verify_Click_Events_Check_Box
 
+    Create Test Error Log
+    Click Element  ${xpath_select_refresh_button}
     # Ensure that page is not in refreshing state.
     Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
-    Click Element  //*[@class='control__indicator']
+    Click Element  ${xpath_select_all_events}
     Page Should Contain Button  ${xpath_event_action_delete}  limit=1
     Page Should Contain Element  ${xpath_event_action_export}  limit=1
 
@@ -127,10 +129,11 @@
 
     Create Test Error Log
     Create Test Error Log
+    Click Element  ${xpath_select_refresh_button}
     Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
     Page Should Contain Element  ${xpath_number_of_events}
     ${number_of_events}=  Get Text  ${xpath_number_of_events}
-    Click Element  //*[@class='control__indicator']
+    Click Element  ${xpath_select_all_events}
     Run Keyword If  ${number_of_events} > 0
     ...  Click Element  ${xpath_mark_as_resolved}
     Element Should Be Disabled  ${xpath_mark_as_resolved}
@@ -142,10 +145,11 @@
 
     Create Test Error Log
     Create Test Error Log
+    Click Element  ${xpath_select_refresh_button}
     Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
     Page Should Contain Element  ${xpath_number_of_events}
     ${number_of_events}=  Get Text  ${xpath_number_of_events}
-    Click Element  //*[@class='control__indicator']
+    Click Element  ${xpath_select_all_events}
     Page Should Contain Element  ${xpath_events_export}
     Run Keyword If  ${number_of_events} > 0
     ...  Click Element  ${xpath_events_export}
@@ -157,13 +161,13 @@
 
     Create Test Error Log
     Create Test Error Log
+    Click Element  ${xpath_select_refresh_button}
     Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}
     Page Should Contain Element  ${xpath_number_of_events}
     ${number_of_events}=  Get Text  ${xpath_number_of_events}
-    Click Element  //*[@class='control__indicator']
-    Page Should Contain Button  ${xpath_event_action_delete}
     Run Keyword If  ${number_of_events} > 0
-    ...  Click Element  ${xpath_event_action_delete}
+    ...  Common Event Log Click Element  ${xpath_individual_event_delete}
+    ...  ${xpath_yes_button}  ${xpath_select_all_events}
     ${number_of_events}=  Get Text  ${xpath_number_of_events}
     Should Be Equal  ${number_of_events}  0
 
@@ -279,14 +283,16 @@
 Common Event Log Click Element
    [Documentation]  Keep common click elements associated with event log.
    [Arguments]  ${action_element}  ${action_click_confirmation}=${None}
+   ...  ${xpath_event_select}=${xpath_individual_event_select}
 
     # Description of argument(s):
     # action_element             xpath value of the element to be actioned
     #                            (e.g. "Delete" or "Resolved" or "Export").
     # action_click_confirmation  Confirmation of action by pressing yes
     #                            (e.g.  "Yes" or "No").
+    # xpath_event_select         xpath to select event log.
 
-    Click Element  ${xpath_individual_event_select}
+    Click Element  ${xpath_event_select}
     Page Should Contain Element  ${action_element}
     Click Element  ${action_element}
     Wait Until Page Does Not Contain Element  ${xpath_refresh_circle}