Skip to content

Commit 85f96c1

Browse files
jsm/upd-comment-action-and-dismiss-popup
1 parent 28b33d8 commit 85f96c1

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

app/selenium_ui/base_page.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,20 @@ def __wait_until(self, expected_condition, locator, time_out=timeout):
132132

133133
return WebDriverWait(self.driver, time_out).until(expected_condition, message=message)
134134

135-
def dismiss_popup(self, *args):
136-
for elem in args:
137-
if self.driver.find_elements(by=By.CSS_SELECTOR, value=elem):
138-
try:
139-
self.driver.execute_script(f"document.querySelector(\'{elem}\').click()")
140-
except(WebDriverException, Exception):
141-
pass
135+
def dismiss_popup(self, popup_selectors):
136+
for selector_type, selector_value in popup_selectors:
137+
if selector_type.lower() == "css":
138+
if self.driver.find_elements(by=By.CSS_SELECTOR, value=selector_value):
139+
try:
140+
self.driver.execute_script(f"document.querySelector('{selector_value}').click()")
141+
except (WebDriverException, Exception):
142+
pass
143+
elif selector_type.lower() == "xpath":
144+
if self.driver.find_elements(by=By.XPATH, value=selector_value):
145+
try:
146+
self.driver.find_element(by=By.XPATH, value=selector_value).click()
147+
except (WebDriverException, Exception):
148+
pass
142149

143150
def return_to_parent_frame(self):
144151
return self.driver.switch_to.parent_frame()

app/selenium_ui/jsm/pages/agent_pages.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
class PopupManager(BasePage):
1010

1111
def dismiss_default_popup(self):
12-
return self.dismiss_popup(PopupLocators.default_popup, PopupLocators.popup_1, PopupLocators.popup_2,
13-
PopupLocators.popup_3, PopupLocators.popup_4,
14-
PopupLocators.popup_5, PopupLocators.popup_6, PopupLocators.popup_7)
12+
return self.dismiss_popup(PopupLocators.popup_selectors)
1513

1614

1715
class Login(BasePage):
@@ -138,10 +136,10 @@ def add_request_comment(self, rte_status):
138136
textarea = self.get_element(ViewCustomerRequestLocators.comment_collapsed_textarea)
139137
self.driver.execute_script("arguments[0].scrollIntoView(true);", textarea)
140138
textarea.click()
141-
if not self.get_elements(ViewCustomerRequestLocators.comment_internally_btn):
142-
comment_button = self.get_element(ViewCustomerRequestLocators.comment_internally_btn_jsm10)
143-
else:
139+
if self.get_elements(ViewCustomerRequestLocators.comment_internally_btn):
144140
comment_button = self.get_element(ViewCustomerRequestLocators.comment_internally_btn)
141+
else:
142+
comment_button = self.get_element(ViewCustomerRequestLocators.comment_internally_btn_jsm10)
145143
self.driver.execute_script("arguments[0].scrollIntoView(true);", comment_button)
146144

147145
if rte_status:

app/selenium_ui/jsm/pages/agent_selectors.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33

44

55
class PopupLocators:
6-
default_popup = '.aui-message .icon-close'
7-
popup_1 = 'form.tip-footer>.helptip-close'
8-
popup_2 = '.aui-inline-dialog-contents .cancel'
9-
popup_3 = '.aui-close-button'
10-
popup_4 = '.aui-button aui-button-link'
11-
popup_5 = '.buttons-container > div > a'
12-
popup_6 = '.css-19r5em7'
13-
popup_7 = '.css-178ag6o'
6+
popup_selectors = [
7+
("css", ".aui-message .icon-close"),
8+
("css", "form.tip-footer>.helptip-close"),
9+
("css", ".aui-inline-dialog-contents .cancel"),
10+
("css", ".aui-close-button"),
11+
("css", ".aui-button aui-button-link"),
12+
("css", ".buttons-container > div > a"),
13+
("css", ".css-19r5em7"),
14+
("css", ".css-178ag6o"),
15+
("xpath", "//button[contains(text(),'Got it')]")
16+
]
1417

1518

1619
class UrlManager:

0 commit comments

Comments
 (0)