-
-
Notifications
You must be signed in to change notification settings - Fork 982
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
[BUG] - playwright._impl._errors.Error: Page.evaluate: ReferenceError: opts is not defined #1172
Comments
Same issue. Here's the code:
And the error:
|
I had the same issue, A quick fix is to downgrade playwright using |
Thanks bro, this can resolve my issue |
Note that this fix is not yet supported for python 3.12. I had to downgrade to 3.11.x to get this to work. |
For me python 3.12 works when using |
Can confirm python 3.12 works with |
我的Python是Python 3.11.7,playwright==1.37.0为何还是不行,我运行时它自动打开tiktok不到2秒就自动关闭了 |
can also confirm as of 8/12/24 python 3.12 works with |
is this API not updated anymore? |
This is a weird issue, I can't seem to figure it out. But it works if you specify
this throws the error
Doesn't, and most other attribute accesses seem to work fine. It feels like a weird way that playwright must've changed handling this in But this script works normally so it might be an issue on how this library is assigning pages? import asyncio
from playwright.async_api import async_playwright
async def run():
async with async_playwright() as playwright:
browser = await playwright.chromium.launch(headless=True) # Set headless=True to run without UI
page = await browser.new_page()
await page.goto('https://tiktok.com')
user_agent = await page.evaluate("() => navigator.userAgent")
print(user_agent)
await page.wait_for_timeout(5000)
await browser.close()
asyncio.run(run()) |
I think this is a playwright specific error, the issue should be posted there |
Traceback (most recent call last):
File "D:\Python\Git\Tiktok\TikTok-Api\examples\user_example.py", line 23, in
asyncio.run(user_example())
File "C:\Users\H\anaconda3\envs\tiktok\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\H\anaconda3\envs\tiktok\lib\asyncio\base_events.py", line 641, in run_until_complete
return future.result()
File "D:\Python\Git\Tiktok\TikTok-Api\examples\user_example.py", line 12, in user_example
await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, proxies=[{"server": "http://127.0.0.1:15732"}])
File "C:\Users\H\anaconda3\envs\tiktok\lib\site-packages\TikTokApi\tiktok.py", line 260, in create_sessions
await asyncio.gather(
File "C:\Users\H\anaconda3\envs\tiktok\lib\site-packages\TikTokApi\tiktok.py", line 201, in __create_session
await self.__set_session_params(session)
File "C:\Users\H\anaconda3\envs\tiktok\lib\site-packages\TikTokApi\tiktok.py", line 94, in __set_session_params
user_agent = await session.page.evaluate("() => navigator.userAgent")
File "C:\Users\H\anaconda3\envs\tiktok\lib\site-packages\playwright\async_api_generated.py", line 8340, in evaluate
await self._impl_obj.evaluate(
File "C:\Users\H\anaconda3\envs\tiktok\lib\site-packages\playwright_impl_page.py", line 440, in evaluate
return await self._main_frame.evaluate(expression, arg)
File "C:\Users\H\anaconda3\envs\tiktok\lib\site-packages\playwright_impl_frame.py", line 278, in evaluate
await self._channel.send(
File "C:\Users\H\anaconda3\envs\tiktok\lib\site-packages\playwright_impl_connection.py", line 59, in send
return await self._connection.wrap_api_call(
File "C:\Users\H\anaconda3\envs\tiktok\lib\site-packages\playwright_impl_connection.py", line 514, in wrap_api_call
raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
playwright._impl._errors.Error: Page.evaluate: ReferenceError: opts is not defined
at Navigator.get [as userAgent] (:11:42)
at eval (eval at evaluate (:226:30), :1:17)
at UtilityScript.evaluate (:233:19)
at UtilityScript. (:1:44)
The text was updated successfully, but these errors were encountered: