Skip to content

Detailed js Console Through Page.Events.Console - #5

Open
JavaScriptDude wants to merge 11 commits into
devfrom
DetailedJSConsole
Open

Detailed js Console Through Page.Events.Console#5
JavaScriptDude wants to merge 11 commits into
devfrom
DetailedJSConsole

Conversation

@JavaScriptDude

Copy link
Copy Markdown
Owner

No description provided.

Sample usage:
```
        page: Page = await browser.newPage()

        def h_js_console(cm: ConsoleMessage):
            for row in cm.toString().split('\n'):
                print(f"[JS CONSOLE] {row}")

        page.on(Page.Events.Console, h_js_console)
```
When running `Pyppeteer` under windows via IIS, it fails because the `AppDirs` scan happens regardless of whether the `PYPPETEER_HOME` environment variable is set or not:

`from pyppeteer import launch` triggers the following Exception:

```
  File "C:\apps\sdk\python\Python38\lib\site-packages\pyppeteer\__init__.py", line 27, in <module>
    __pyppeteer_home__ = os.environ.get('PYPPETEER_HOME', AppDirs('pyppeteer').user_data_dir)  # type: str
  File "C:\apps\sdk\python\Python38\lib\site-packages\appdirs.py", line 419, in user_data_dir
    return user_data_dir(self.appname, self.appauthor,
  File "C:\apps\sdk\python\Python38\lib\site-packages\appdirs.py", line 81, in user_data_dir
    path = os.path.normpath(_get_win_folder(const))
  File "C:\apps\sdk\python\Python38\lib\site-packages\appdirs.py", line 481, in _get_win_folder_with_pywin32
    dir = shell.SHGetFolderPath(0, getattr(shellcon, csidl_name), 0, 0)
pywintypes.com_error: (-2147024891, 'Access is denied.', None, None)
```

Reason for failure: The System user used by IIS does not have a `user_data_dir`. This issue will likely occur for other system processes under windows.
Also truncate the machine date/time format
With the exception of adding the timestamp which puppeteer did not implement at this time.
Included more extensibility of toString() functionality by including a callback for user specified stringifier.
New method is getData(). Done to aid in consuming method from user code and tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant