Skip to content

Commit

Permalink
Improve create_tab() and create _id_zero attribute at Protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
neyberson committed Aug 15, 2024
1 parent 5bf493a commit 75b752c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions devtools/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ def __init__(self, browser_pipe):
self.browser_session = Session(self, session_id="")
self.tabs = OrderedDict()
self.browser_pipe = browser_pipe
self._id_zero = True

def create_tab(self):
tab_obj = Tab()
tab_obj.id = next(reversed(self.tabs.keys())) + 1
self.tabs[tab_obj.id] = tab_obj
if self._id_zero and 0 not in self.tabs.keys():
self._id_zero = False
self.tabs[tab_obj.id] = tab_obj
else:
tab_obj.id = next(reversed(self.tabs.keys())) + 1
self.tabs[tab_obj.id] = tab_obj
print(f"New Tab Created: {tab_obj.id}")
return tab_obj

Expand Down

0 comments on commit 75b752c

Please sign in to comment.