1
1
from s_tool .driver import SeleniumDriver
2
- from s_tool .parser import select_options
2
+ from s_tool .parser import get_table , select_options
3
3
4
4
from . import TEST_URL
5
5
@@ -10,16 +10,16 @@ def test_select():
10
10
obj .get (TEST_URL )
11
11
12
12
# Test dropdown options with element id
13
- options_dicts = select_options (obj .element ("id" , " sel1" ))
13
+ options_dicts = select_options (obj .element ("sel1" ))
14
14
actual_result = {"1" : "1" , "2" : "2" , "3" : "3" , "4" : "4" }
15
15
assert options_dicts == actual_result
16
16
17
17
# Test for invalid element
18
- options_dicts = select_options (obj .element ("id " , "select_id " ))
18
+ options_dicts = select_options (obj .element ("select_id " , "id " ))
19
19
assert options_dicts == {}
20
20
21
21
# Test for disabled dropdown
22
- options_dicts = select_options (obj .element ("xpath" , '//select[@disabled=""]' ))
22
+ options_dicts = select_options (obj .element ('//select[@disabled=""]' , "xpath" ))
23
23
assert options_dicts == {
24
24
"default" : "default" ,
25
25
"1" : "One" ,
@@ -28,11 +28,19 @@ def test_select():
28
28
}
29
29
30
30
# Test for swaping keys and values\
31
- elem = obj .element ("xpath" , '//select[@disabled=""]' )
31
+ elem = obj .element ('//select[@disabled=""]' , "xpath" )
32
32
options_dicts = select_options (elem , swap = True )
33
33
assert options_dicts == {
34
34
"default" : "default" ,
35
35
"One" : "1" ,
36
36
"Two" : "2" ,
37
37
"Three" : "3" ,
38
38
}
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