Skip to content

Commit 237a92a

Browse files
authored
Merge pull request #65 from Python-World/STOOL2
added default chrome driver if browser and driver not provided
2 parents 90732f0 + e243734 commit 237a92a

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

Diff for: README.rst

+11-12
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ Usage
4444

4545
.. code-block:: python
4646
47-
"""Example code with context manager"""
47+
"""Example code with context manager"""
4848
49-
from s_tool.core import SeleniumDriver as SBot
49+
from s_tool.core import SeleniumTools as SBot
5050
51-
with SBot("firefox", headless=True) as self:
52-
self.get("https://google.com")
53-
sessionid = self.session()
54-
url = self.url()
55-
cookies = self.cookies()
56-
57-
# print sessionid,url,cookies
58-
print(f"\nurl : {url} \nsession : {sessionid}\ncookies : {cookies}\n")
51+
with SBot(browser="firefox", headless=True) as self:
52+
self.get("https://example.com")
53+
sessionid = self.sessionid()
54+
url = self.url()
55+
cookies = self.cookies()
5956
57+
# print sessionid,url,cookies
58+
print(f"\nurl : {url} \nsession : {sessionid}\ncookies : {cookies}\n")
59+
6060
6161
* Example Using class
6262

@@ -84,8 +84,7 @@ Usage
8484
8585
bot = SBot(browser ="firefox", headless=True) # change headless=False to run with gui mode
8686
bot.run()
87-
bot.close()
88-
87+
bot._close()
8988
9089
Methods
9190
^^^^^^^

Diff for: s_tool/core.py

+6
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def __enter__(self):
7474

7575
def _load_driver(self):
7676
"""Create Selenium webdriver object"""
77+
if self.browser is None:
78+
self.browser='chrome'
79+
7780
obj = SeleniumDriver(browser=self.browser,
7881
headless=self.headless,
7982
executable_path=self.executable_path)
@@ -204,6 +207,9 @@ def _validate_driver(self) -> None:
204207
err = "Selenium WebDriver validation failed."
205208
supported_browsers = self._get_supported_browsers()
206209

210+
if self.driver is None:
211+
return False
212+
207213
if hasattr(
208214
self.driver,
209215
'name') and self.driver.name not in supported_browsers:

0 commit comments

Comments
 (0)