Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now setting load order once for every new suite #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions src/SeleniumLibraryToBrowser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,37 +577,33 @@ def selenium_speed(self, value: Union[float, str, timedelta]):

@property
def b(self) -> Browser:
if self._browser is None:
self._browser = None
self._browser_name = None
self._sl2b_name = None
current_suite = BuiltIn().get_variable_value("${SUITE_SOURCE}")
if not hasattr(self, '_suite') or self._suite != current_suite:
self._browser_lib = None
browser_lib_name = None
sl2b_name = None
for name, lib in BuiltIn().get_library_instance(all=True).items():
if isinstance(lib, Browser):
self._browser = lib
self._browser_name = name
browser_lib_name = name
self._browser_lib = lib
elif isinstance(lib, SeleniumLibraryToBrowser):
self._sl2b_name = name
if self._browser is None:
sl2b_name = name

if self._browser_lib is None:
self._browser_args["timeout"] = self._implicit_wait
self._browser = Browser(**self._browser_args)
self._browser.set_strict_mode(False, Scope.Global)
self._browser._auto_closing_level = AutoClosingLevel.MANUAL
self._browser_lib = Browser(**self._browser_args)
self._browser_lib.set_strict_mode(False, Scope.Global)
self._browser_lib._auto_closing_level = AutoClosingLevel.MANUAL
self.b.set_browser_timeout(self.implicit_wait, scope=Scope.Global)

if self.prioritize_library == PriorityLibrary.Browser:
BuiltIn().set_library_search_order(self._browser_name or "Browser")
BuiltIn().set_library_search_order(browser_lib_name or "Browser")
elif self.prioritize_library == PriorityLibrary.SeleniumLibraryToBrowser:
BuiltIn().set_library_search_order(self._sl2b_name or "SeleniumLibraryToBrowser")
elif (
self._sl2b_name is not None
and self.prioritize_library == PriorityLibrary.SeleniumLibraryToBrowser
):
for name, lib in BuiltIn().get_library_instance(all=True).items():
if isinstance(lib, SeleniumLibraryToBrowser):
self._sl2b_name = name
BuiltIn().set_library_search_order(self._sl2b_name)
return self._browser
BuiltIn().set_library_search_order(sl2b_name or "SeleniumLibraryToBrowser")

@property
self._suite = BuiltIn().get_variable_value("${SUITE_SOURCE}")

return self._browser_lib @property
def library_comp(self) -> LibraryComponent:
return LibraryComponent(self.b)

Expand Down