File tree 2 files changed +17
-12
lines changed
2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -44,19 +44,19 @@ Usage
44
44
45
45
.. code-block :: python
46
46
47
- """ Example code with context manager"""
47
+ """ Example code with context manager"""
48
48
49
- from s_tool.core import SeleniumDriver as SBot
49
+ from s_tool.core import SeleniumTools as SBot
50
50
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 " \n url : { url} \n session : { sessionid} \n cookies : { 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()
59
56
57
+ # print sessionid,url,cookies
58
+ print (f " \n url : { url} \n session : { sessionid} \n cookies : { cookies} \n " )
59
+
60
60
61
61
* Example Using class
62
62
84
84
85
85
bot = SBot(browser = " firefox" , headless = True ) # change headless=False to run with gui mode
86
86
bot.run()
87
- bot.close()
88
-
87
+ bot._close()
89
88
90
89
Methods
91
90
^^^^^^^
Original file line number Diff line number Diff line change @@ -74,6 +74,9 @@ def __enter__(self):
74
74
75
75
def _load_driver (self ):
76
76
"""Create Selenium webdriver object"""
77
+ if self .browser is None :
78
+ self .browser = 'chrome'
79
+
77
80
obj = SeleniumDriver (browser = self .browser ,
78
81
headless = self .headless ,
79
82
executable_path = self .executable_path )
@@ -204,6 +207,9 @@ def _validate_driver(self) -> None:
204
207
err = "Selenium WebDriver validation failed."
205
208
supported_browsers = self ._get_supported_browsers ()
206
209
210
+ if self .driver is None :
211
+ return False
212
+
207
213
if hasattr (
208
214
self .driver ,
209
215
'name' ) and self .driver .name not in supported_browsers :
You can’t perform that action at this time.
0 commit comments