Detailed js Console Through Page.Events.Console - #5
Open
JavaScriptDude wants to merge 11 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.