robotframework-browserpom 0.6.0__tar.gz → 0.6.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ from typing import TYPE_CHECKING, cast
7
7
 
8
8
  from Browser import Browser
9
9
  from Browser.utils import ScreenshotFileTypes, ScreenshotReturnType
10
+ from robot.api import logger
10
11
  from robot.api.deco import keyword
11
12
  from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
12
13
 
@@ -135,7 +136,25 @@ class BrowserPOM(Browser):
135
136
  kwargs["jsextension"] = jsextensions
136
137
 
137
138
  browser_init = cast("Callable[..., None]", super().__init__)
138
- browser_init(*args, **kwargs)
139
+ try:
140
+ browser_init(*args, **kwargs)
141
+ except Exception as error: # noqa: BLE001
142
+ # Passing a ``jsextension`` makes BrowserLibrary eagerly start the
143
+ # Playwright Node.js process during ``__init__`` (to register the JS
144
+ # keywords). When BrowserPOM is only imported so another library or
145
+ # tool can gather its keywords, that spawn can fail in fork-unsafe
146
+ # contexts (e.g. grpc already initialised, pabot,
147
+ # pytest_robotframework), raising errors such as
148
+ # "TypeError: 'NoneType' object is not callable" from subprocess.
149
+ # Fall back to a plain init so keyword gathering does not crash the
150
+ # importing library.
151
+ logger.warn(
152
+ "BrowserPOM: failed to load the 'filter_locator' jsextension "
153
+ f"during import ({error}). The library was initialised without "
154
+ "it so keyword gathering can continue.",
155
+ )
156
+ kwargs["jsextension"] = [extension for extension in jsextensions if extension != str(addon_path)] or None
157
+ browser_init(*args, **kwargs)
139
158
 
140
159
  @keyword
141
160
  def take_screenshot(self, *args, **kwargs): # noqa:ANN002,ANN003,ANN201
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: robotframework-browserpom
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: robotframework-browser library extension to create Page Objects
5
5
  Author-email: Hasan Alp Zengin <hasanalpzengin@gmail.com>
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "robotframework-browserpom"
3
- version = "0.6.0"
3
+ version = "0.6.1"
4
4
  description = "robotframework-browser library extension to create Page Objects"
5
5
  authors = [{ name = "Hasan Alp Zengin", email = "hasanalpzengin@gmail.com" }]
6
6
  requires-python = ">=3.9,<4.0"