1#!/usr/bin/python
2
3r"""
4Contains xpaths and related string constants applicable to all openBMC GUI
5menus.
6"""
7
8
9class resource_variables():
10
11    xpath_textbox_hostname = "//input[@id='host']"
12    xpath_textbox_username = "//input[@id='username']"
13    xpath_textbox_password = "//input[@id='password']"
14    xpath_button_login = "//*[@id='login__submit']"
15    xpath_button_logout = '//a[contains(text(), "Log out")]'
16    xpath_yes_button = "//button[text()='Yes']"
17    xpath_openbmc_url = "http://localhost:8080/#/login"
18    xpath_openbmc_ip = "//*[@id='login__form']/input[1]"
19    xpath_power_indicator = "//*[@id='power-indicator-bar']"
20    xpath_select_button_power_on = "//*[@id='power__power-on']"
21    xpath_cancel_button = "//button[contains(text(),'Cancel')]"
22    xpath_save_setting_button = "//button[contains(text(),'Save settings')]"
23
24    xpath_select_button_warm_reboot = \
25        "//*[@id='power__warm-boot']"
26    xpath_operation_warning_message = \
27        "//*[@class='inline__confirm active']"
28    xpath_select_button_warm_reboot_no = \
29        "//*[@id='power-operations']/div[3]" \
30        "/div[3]/confirm/div/div[2]/button[2]"
31    text_warm_reboot_warning_message = "warm reboot?"
32    xpath_select_button_warm_reboot_yes = \
33        "//*[@id='power-operations']" \
34        "/div[3]/div[3]/confirm/div/div[2]/button[1]"
35
36    xpath_select_button_cold_reboot = \
37        "//*[@id='power__cold-boot']"
38    xpath_select_button_cold_reboot_no = \
39        "//*[@id='power-operations']/div[3]/div[4]" \
40        "/confirm/div/div[2]/button[2]"
41    text_cold_reboot_warning_message = "cold reboot?"
42    xpath_select_button_cold_reboot_yes = \
43        "//*[@id='power-operations']" \
44        "/div[3]/div[4]/confirm/div/div[2]/button[2]"
45
46    xpath_select_button_orderly_shutdown = \
47        "//*[@id='power__soft-shutdown']"
48    xpath_select_button_orderly_shutdown_button_no = \
49        "//*[@id='power-operations']/div[3]/div[5]"\
50        "/confirm/div/div[2]/button[2]"
51    text_orderly_shutdown_warning_message = "orderly shutdown?"
52    xpath_select_button_orderly_shutdown_yes = \
53        "//*[@id='power-operations']/div[3]/div[5]" \
54        "/confirm/div/div[2]/button[1]"
55
56    xpath_select_button_immediate_shutdown = \
57        "//*[@id='power__hard-shutdown']"
58    xpath_select_button_immediate_shutdown_no = \
59        "//*[@id='power-operations']/div[3]/div[6]" \
60        "/confirm/div/div[2]/button[2]"
61    text_immediate_shutdown_warning_message = "immediate shutdown?"
62    xpath_select_button_immediate_shutdown_yes = \
63        "//*[@id='power-operations']/div[3]/div[6]" \
64        "/confirm/div/div[2]/button[1]"
65
66    obmc_off_state = "Off"
67    obmc_standby_state = "Standby"
68    obmc_running_state = "Running"
69
70    # xpath for main menu.
71    xpath_select_server_control = "//button[contains(@class,'btn-control')]"
72    xpath_select_server_configuration = "//button[contains(@class,'btn-config')]"
73
74    # xpath for sub main menu.
75    xpath_select_server_power_operations = "//a[@href='#/server-control/power-operations']"
76    xpath_select_snmp_settings = "//a[@href='#/configuration/snmp']"
77
78    # Power operation elements needed for power on.
79    header_wrapper = "3"
80    header_wrapper_elt = "3"
81
82    # Power operation elements needed for power operations confirmation.
83    power_operations = "3"
84    warm_boot = "3"
85    cold_boot = "4"
86    shut_down = "5"
87    power_off = "6"
88    confirm_msg = "2"
89    yes = "1"
90    No = "2"
91
92    # GUI header elements locators.
93    xpath_select_server_power = "//a[@href='#/server-control/power-operations']"
94
95    # Server health elements locators.
96    xpath_select_server_health = "//a[@href='#/server-health/event-log']"
97    xpath_server_health_text =  \
98        "//*[@id='header__wrapper']/div/div[3]/a[2]/span"
99    xpath_select_refresh_button = \
100        "//*[contains(text(),'Refresh')]"
101    xpath_event_severity_all = "//*[text()='Filter by severity']/following-sibling::button[1]"
102    xpath_event_severity_high = "//*[text()='Filter by severity']/following-sibling::button[2]"
103    xpath_event_severity_medium = "//*[text()='Filter by severity']/following-sibling::button[3]"
104    xpath_event_severity_low = "//*[text()='Filter by severity']/following-sibling::button[4]"
105    xpath_drop_down_timezone_edt = \
106        "//*[@id='event-log']/section[1]/div/div/button"
107    xpath_refresh_circle = "/html/body/main/loader/div[1]/svg/circle"
108    xpath_drop_down_timezone_utc =  \
109        "//*[@id='event-log']/section[1]/div/div/ul/li[2]/button"
110    xpath_event_filter_all = "//*[text()='All events']"
111    xpath_event_filter_resolved = "//*[text()='Resolved events']"
112    xpath_event_filter_unresolved = "//*[text()='Unresolved events']"
113    xpath_event_action_bars = \
114        "//*[@id='event__actions-bar']/div[1]/label/span"
115    xpath_event_action_delete = \
116        "//*[@id='event__actions-bar']/div[2]/div[2]/button[1]"
117    xpath_event_action_export = \
118        "//*[@id='event__actions-bar']/div[2]/div[2]/a"
119    xpath_number_of_events = \
120        "//*[@id='event__actions-bar']/div[2]/p[2]/span"
121    xpath_mark_as_resolved = \
122        "//*[@id='event__actions-bar']/div[2]/div[2]/button[2]"
123    xpath_events_export = "//*[@id='event__actions-bar']/div[2]/div[2]/a"
124    xpath_event_delete_no = \
125        "//*[@id='event__actions-bar']/div[2]/div[1]/div[2]/button[2]"
126    xpath_event_delete_yes = \
127        "//*[@id='event__actions-bar']/div[2]/div[1]/div[2]/button[1]"
128    xpath_individual_event_select = "(//*[@class='control__indicator'])[2]"
129    xpath_individual_event_delete = \
130        "//*[@id='event__actions-bar']/div[2]/div[2]/button[1]"
131    xpath_second_event_select = "(//*[@class='control__indicator'])[3]"
132    xpath_individual_event_resolved = \
133        "//*[@id='event__actions-bar']/div[2]/div[2]/button[2]"
134    xpath_individual_event_export = \
135        "//*[@id='event__actions-bar']/div[2]/div[2]/a"
136    xpath_select_all_events = "(//*[@class='control__indicator'])[1]"
137