Browser automation using Playwright Python to periodically sign in to various accounts and export logs to a private repo https://github.com/schmwong/login-log
Mega had a minor update in which the anchor link to the dashboard (a.dashboard-link) got replaced by a button (div[name=dashboard][aria-role=button]).
Fix
In the module login_logger.py, this PR adds to the redirect method an option to click if a button selector is used in the keyword argument instead of the previously used href selector.
GitHub Actions log output before fix:
2024-04-19 06:46:17:780199 INFO Launching browser
2024-04-19 06:46:19:722025 INFO Retrieving login page 'https://mega.nz/login'
2024-04-19 06:46:22:466234 INFO Logging in
2024-04-19 06:46:26:999902 INFO Logged in successfully
Traceback (most recent call last):
File "/home/runner/work/keep-accounts-active/keep-accounts-active/keep-mega-active.py", line 110, in <module>
mega_login(instance)
File "/home/runner/work/keep-accounts-active/keep-accounts-active/keep-mega-active.py", line 85, in mega_login
instance.redirect(href_sel="a.dashboard-link")
File "/home/runner/work/keep-accounts-active/keep-accounts-active/login_logger.py", line 150, in redirect
).get_attribute("href")
File "/home/runner/.local/lib/python3.10/site-packages/playwright/sync_api/_generated.py", line 16143, in get_attribute
self._sync(self._impl_obj.get_attribute(name=name, timeout=timeout))
File "/home/runner/.local/lib/python3.10/site-packages/playwright/_impl/_sync_base.py", line 115, in _sync
return task.result()
File "/home/runner/.local/lib/python3.10/site-packages/playwright/_impl/_locator.py", line 409, in get_attribute
return await self._frame.get_attribute(
File "/home/runner/.local/lib/python3.10/site-packages/playwright/_impl/_frame.py", line 628, in get_attribute
return await self._channel.send("getAttribute", locals_to_params(locals()))
File "/home/runner/.local/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 59, in send
return await self._connection.wrap_api_call(
File "/home/runner/.local/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 5[13](https://github.com/schmwong/keep-accounts-active/actions/runs/8749543593/job/24011405441#step:6:14), in wrap_api_call
raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
playwright._impl._errors.TimeoutError: Locator.get_attribute: Timeout 30000ms exceeded.
Call log:
waiting for locator("a.dashboard-link")
GitHub Actions log output after fix:
2024-04-19 16:16:56:989620 INFO Launching browser
2024-04-19 16:17:00:454167 INFO Retrieving login page 'https://mega.nz/login'
2024-04-19 16:17:04:317800 INFO Logging in
2024-04-19 16:17:08:563317 INFO Logged in successfully
2024-04-19 16:17:10:129413 INFO Getting storage details from 'https://mega.nz/fm/dashboard'
2024-04-19 16:17:10:129647 DEBUG Profile name: p w
2024-04-19 16:17:10:129730 DEBUG Email: ***
2024-04-19 16:17:10:129800 DEBUG Plan: Free
2024-04-19 16:17:10:172876 DEBUG Cloud drive: (15.68 GB)
2024-04-19 16:17:10:199614 DEBUG Backups: 0 MB
2024-04-19 16:17:10:218342 DEBUG Versions: (0 B)
2024-04-19 16:17:10:233826 DEBUG Rubbish bin: (0 B)
2024-04-19 16:17:10:252806 DEBUG Available: (34.32 GB)
2024-04-19 16:17:10:252871 INFO Tasks complete. Closing browser
2024-04-19 16:17:10:979562 INFO Launching browser
2024-04-19 16:17:13:044524 INFO Retrieving login page 'https://mega.nz/login'
2024-04-19 16:17:16:129997 INFO Logging in
2024-04-19 16:17:21:160412 INFO Logged in successfully
2024-04-19 16:17:22:831190 INFO Getting storage details from 'https://mega.nz/fm/dashboard'
2024-04-19 16:17:22:831361 DEBUG Profile name: s w
2024-04-19 16:17:22:831441 DEBUG Email: ***
2024-04-19 16:17:22:831496 DEBUG Plan: Free
2024-04-19 16:17:22:881597 DEBUG Cloud drive: (7.30 GB)
2024-04-19 16:17:22:903373 DEBUG Backups: 0 MB
2024-04-19 16:17:22:918438 DEBUG Versions: (0 B)
2024-04-19 16:17:22:933787 DEBUG Rubbish bin: (0 B)
2024-04-19 16:17:22:949115 DEBUG Available: (42.70 GB)
2024-04-19 16:17:22:949335 INFO Tasks complete. Closing browser
Issue
Mega had a minor update in which the anchor link to the dashboard (
a.dashboard-link
) got replaced by a button (div[name=dashboard][aria-role=button]
).Fix
In the module
login_logger.py
, this PR adds to theredirect
method an option to click if a button selector is used in the keyword argument instead of the previously used href selector.GitHub Actions log output before fix:
GitHub Actions log output after fix: