Skip to content

Commit 1b9c1ac

Browse files
committed
fix selenium helper calls in field handler
1 parent 4d19f3a commit 1b9c1ac

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ docs/_build/
5353

5454
# PyBuilder
5555
target/
56+
57+
# OS generated files
58+
.DS_Store
59+
.DS_Store?

tests/test_field_handler.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,14 @@ def test_dispatch_general_exception_with_name(self, text_method):
226226
#--- Handle Text
227227
def test_handle_text_without_confirm(self):
228228
self.fh.handle_text("selector", "input text")
229-
self.sh.fill_an_element.assert_called_once_with("selector", "input text")
229+
self.sh.fill_an_element.assert_called_once_with(css_selector="selector", fill_text="input text")
230230

231231
def test_handle_text_with_confirm(self):
232232
css_selector = "selector"
233233
input_text = "input text"
234234
confirm_css_selector = "confirm"
235235
self.fh.handle_text(css_selector, input_text, confirm_css_selector)
236-
self.sh.fill_an_element.assert_called_with(confirm_css_selector, input_text)
236+
self.sh.fill_an_element.assert_called_with(css_selector=confirm_css_selector, fill_text=input_text)
237237

238238
def test_handle_text_selenium_exception(self):
239239
self.sh.fill_an_element.side_effect = selenium_helpers.SeleniumHelperExceptions("message text",
@@ -251,7 +251,7 @@ def test_handle_text_general_exception(self):
251251
def test_handle_check_box(self):
252252
enum = [{"css_selector": "selector.1"}, {"css_selector": "selector.2"}]
253253
self.fh.handle_check_box(enum, [0, 1])
254-
self.sh.click_an_element.assert_called_with(enum[1]["css_selector"])
254+
self.sh.click_an_element.assert_called_with(css_selector=enum[1]["css_selector"])
255255

256256
def test_handle_check_box_key_error(self):
257257
enum = [{"bad_key": "selector.1"}, {"css_selector": "selector.2"}]
@@ -277,7 +277,7 @@ def test_handle_check_box_general_exception(self):
277277
def test_handle_radio_button(self):
278278
enum = [{"css_selector": "selector.1"}, {"css_selector": "selector.2"}]
279279
self.fh.handle_radio_button(enum, 1)
280-
self.sh.click_an_element.assert_called_with(enum[1]["css_selector"])
280+
self.sh.click_an_element.assert_called_with(css_selector=enum[1]["css_selector"])
281281

282282
def test_handle_radio_button_key_error(self):
283283
enum = [{"bad_key": "selector.1"}, {"css_selector": "selector.1"}]
@@ -303,12 +303,12 @@ def test_handle_radio_button_general_exception(self):
303303
def test_handle_select_with_first_invalid(self):
304304
selector = "select.1"
305305
self.fh.handle_select(selector, 1)
306-
self.sh.click_an_element.assert_called_once_with("{0} option:nth-child({1})".format(selector, 3))
306+
self.sh.click_an_element.assert_called_once_with(css_selector="{0} option:nth-child({1})".format(selector, 3))
307307

308308
def test_handle_select_with_first_valid(self):
309309
selector = "select.1"
310310
self.fh.handle_select(selector, 1, True)
311-
self.sh.click_an_element.assert_called_once_with("{0} option:nth-child({1})".format(selector, 2))
311+
self.sh.click_an_element.assert_called_once_with(css_selector="{0} option:nth-child({1})".format(selector, 2))
312312

313313
def test_handle_select_selenium_exception(self):
314314
self.sh.click_an_element.side_effect = selenium_helpers.SeleniumHelperExceptions("message text",
@@ -328,7 +328,7 @@ def test_handle_drop_down(self):
328328
css_selector = "selector.1"
329329
enum = [{"css_selector": "selector.1"}, {"css_selector": "selector.2"}]
330330
self.fh.handle_drop_down(css_selector, enum, 1)
331-
self.sh.click_an_element.assert_called_with(enum[1]["css_selector"])
331+
self.sh.click_an_element.assert_called_with(css_selector=enum[1]["css_selector"])
332332

333333
def test_handle_drop_down_key_error(self):
334334
css_selector = "selector.1"
@@ -355,7 +355,7 @@ def test_handle_drop_down_general_exception(self):
355355
def test_handle_button(self):
356356
css_selector = "selector.1"
357357
self.fh.handle_button(css_selector)
358-
self.sh.click_an_element.assert_called_with(css_selector)
358+
self.sh.click_an_element.assert_called_with(css_selector=css_selector)
359359

360360
def test_handle_button_selenium_exception(self):
361361
css_selector = "selector.1"

the_ark/field_handlers.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ def handle_text(self, css_selector="", input_text="", confirm_css_selector=None)
108108
"""
109109
try:
110110
#--- Handle the field
111-
self.sh.fill_an_element(css_selector, input_text)
111+
self.sh.fill_an_element(css_selector=css_selector, fill_text=input_text)
112112
#- Fill in the confirm field as well, if provided
113113
if confirm_css_selector:
114-
self.sh.fill_an_element(confirm_css_selector, input_text)
114+
self.sh.fill_an_element(css_selector=confirm_css_selector, fill_text=input_text)
115115

116116
except selenium_helpers.SeleniumHelperExceptions as selenium_error:
117117
message = "A selenium issue arose while handling the text field."
@@ -141,7 +141,7 @@ def handle_check_box(self, enums, input_indexes):
141141
#--- Handle the field
142142
for index in input_indexes:
143143
current_test_index = index
144-
self.sh.click_an_element(enums[index]["css_selector"])
144+
self.sh.click_an_element(css_selector=enums[index]["css_selector"])
145145

146146
except KeyError as key:
147147
message = "Key {0} is missing from the dictionary at " \
@@ -171,7 +171,7 @@ def handle_radio_button(self, enums, input_index):
171171
"""
172172
try:
173173
#--- Handle the field
174-
self.sh.click_an_element(enums[input_index]["css_selector"])
174+
self.sh.click_an_element(css_selector=enums[input_index]["css_selector"])
175175

176176
except KeyError as key:
177177
message = "Key {0} is missing from the dictionary at " \
@@ -205,7 +205,7 @@ class to interact with the field.
205205
if first_valid:
206206
index_offset = 1
207207

208-
self.sh.click_an_element("{0} option:nth-child({1})".format(
208+
self.sh.click_an_element(css_selector="{0} option:nth-child({1})".format(
209209
css_selector, input_index + index_offset))
210210

211211
except selenium_helpers.SeleniumHelperExceptions as selenium_error:
@@ -234,9 +234,9 @@ def handle_drop_down(self, css_selector, enums, input_index):
234234
try:
235235
#--- Handle the field
236236
#- Click the parent element to reveal the options
237-
self.sh.click_an_element(css_selector)
237+
self.sh.click_an_element(css_selector=css_selector)
238238
#- Click the option that corresponds with the css_selector in the given index of the enum
239-
self.sh.click_an_element(enums[input_index]["css_selector"])
239+
self.sh.click_an_element(css_selector=enums[input_index]["css_selector"])
240240

241241
except KeyError as key:
242242
message = "Key {0} is missing from the dictionary at " \
@@ -261,7 +261,7 @@ def handle_button(self, css_selector):
261261
- css_selector: string - The element's css selector in the webpage's DOM.
262262
"""
263263
try:
264-
self.sh.click_an_element(css_selector)
264+
self.sh.click_an_element(css_selector=css_selector)
265265

266266
except selenium_helpers.SeleniumHelperExceptions as selenium_error:
267267
message = "A selenium issue arose while attempting to select click the button"

0 commit comments

Comments
 (0)