Skip to content

Commit 4fe7488

Browse files
author
ravishankar
committed
testcases added for dropdown and table
1 parent fa19bcc commit 4fe7488

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

tests/test_elements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def test_select_box():
99

1010
select_value = "1"
1111
obj.fill({"select_dropdown": select_value})
12-
element = obj.element("name", "select_dropdown")
12+
element = obj.element("select_dropdown", "name")
1313
for ele in element.find_elements_by_tag_name("option"):
1414
if ele.text == "One":
1515
assert ele.is_selected() is True

tests/test_parser.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from s_tool.driver import SeleniumDriver
2-
from s_tool.parser import select_options
2+
from s_tool.parser import get_table, select_options
33

44
from . import TEST_URL
55

@@ -10,16 +10,16 @@ def test_select():
1010
obj.get(TEST_URL)
1111

1212
# Test dropdown options with element id
13-
options_dicts = select_options(obj.element("id", "sel1"))
13+
options_dicts = select_options(obj.element("sel1"))
1414
actual_result = {"1": "1", "2": "2", "3": "3", "4": "4"}
1515
assert options_dicts == actual_result
1616

1717
# Test for invalid element
18-
options_dicts = select_options(obj.element("id", "select_id"))
18+
options_dicts = select_options(obj.element("select_id", "id"))
1919
assert options_dicts == {}
2020

2121
# Test for disabled dropdown
22-
options_dicts = select_options(obj.element("xpath", '//select[@disabled=""]'))
22+
options_dicts = select_options(obj.element('//select[@disabled=""]', "xpath"))
2323
assert options_dicts == {
2424
"default": "default",
2525
"1": "One",
@@ -28,11 +28,19 @@ def test_select():
2828
}
2929

3030
# Test for swaping keys and values\
31-
elem = obj.element("xpath", '//select[@disabled=""]')
31+
elem = obj.element('//select[@disabled=""]', "xpath")
3232
options_dicts = select_options(elem, swap=True)
3333
assert options_dicts == {
3434
"default": "default",
3535
"One": "1",
3636
"Two": "2",
3737
"Three": "3",
3838
}
39+
40+
41+
def test_table():
42+
with SeleniumDriver("chrome", headless=True) as obj:
43+
obj.get(TEST_URL)
44+
table = obj.element('//table[@class="table"]', "xpath")
45+
table_data = get_table(table)
46+
assert len(table_data) == 4

0 commit comments

Comments
 (0)