Skip to content

Commit 418d992

Browse files
committed
impproved parser
1 parent 0d18a35 commit 418d992

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

tests/test_core.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def setUpClass(cls):
2929
options.add_argument('--disable-gpu') # Last I checked this was necessary.
3030

3131
cls.driver = webdriver.Chrome(chrome_options=options,service=ChromeService(ChromeDriverManager().install()))
32-
cls.selenium_tools = SeleniumTools(driver=cls.driver,parser_class=LXMLParser)
32+
cls.selenium_tools = SeleniumTools(driver=cls.driver,parser=LXMLParser)
3333
cls.url = "https://www.example.com/"
3434
cls.example_file =os.path.join(os.path.dirname(__file__),'data/example.html')
3535
cls.selenium_tools.get(cls.url)
@@ -44,8 +44,8 @@ def test_get_supported_browsers(self):
4444
self.assertIsInstance(supported_browsers, list)
4545
self.assertGreater(len(supported_browsers), 0)
4646

47-
def test_get_driver_sessionid(self):
48-
session_id = self.selenium_tools.get_driver_sessionid()
47+
def test_sessionid(self):
48+
session_id = self.selenium_tools.sessionid()
4949
self.assertIsInstance(session_id, str)
5050
self.assertGreater(len(session_id), 0)
5151

tests/test_parser.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
import unittest
3+
4+
from s_tool.parser import LxmlParser
5+
6+
7+
class LxmlParserTestCase(unittest.TestCase):
8+
@classmethod
9+
def setUpClass(cls):
10+
cls.parser = LxmlParser()
11+
12+
def test_dropdown(self):
13+
html_string = """
14+
<html>
15+
<body>
16+
<select>
17+
<option value="1">Option 1</option>
18+
<option value="2">Option 2</option>
19+
<option value="3">Option 3</option>
20+
</select>
21+
</body>
22+
</html>"""
23+
24+
expected_result = [('Option 1', '1'), ('Option 2', '2'), ('Option 3', '3')]
25+
dropdown_options = self.parser.dropdown(html_string)
26+
27+
self.assertEqual(expected_result,dropdown_options)
28+
self.assertTrue(len(dropdown_options)==3)
29+

0 commit comments

Comments
 (0)