Skip to content

Commit 322938e

Browse files
author
ravishankar
committed
examples added
1 parent dd7c804 commit 322938e

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

examples/with_class_object.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Example code with class"""
2+
3+
from s_tool.driver import SeleniumDriver
4+
5+
6+
class SBot(SeleniumDriver):
7+
"""Example Bot using s-tool"""
8+
9+
def __init__(self, *args, **kwargs):
10+
super().__init__(*args, **kwargs)
11+
12+
def run(self):
13+
self.get("https://google.com")
14+
sessionid = self.session()
15+
url = self.url()
16+
cookies = self.cookies()
17+
18+
# print sessionid,url,cookies
19+
print(f"\nurl : {url} \nsession : {sessionid}\ncookies : {cookies}\n")
20+
21+
22+
bot = SBot("firefox", headless=True) # change headless=False to run with gui mode
23+
bot.run()
24+
bot.close()

examples/with_context_manager.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Example code with context manager"""
2+
3+
from s_tool.driver import SeleniumDriver as SBot
4+
5+
with SBot("firefox", headless=True) as self:
6+
self.get("https://google.com")
7+
sessionid = self.session()
8+
url = self.url()
9+
cookies = self.cookies()
10+
11+
# print sessionid,url,cookies
12+
print(f"\nurl : {url} \nsession : {sessionid}\ncookies : {cookies}\n")

0 commit comments

Comments
 (0)