question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] - Neither playwright nor selenium seem to work

See original GitHub issue

Describe the bug

Cannot get tiktok api instance

The buggy code

Please insert the code that is throwing errors or is giving you weird unexpected results.

from TikTokApi import TikTokApi
api = TikTokApi.get_instance()

Expected behavior

I should get the tiktok api object without any error

Error Trace (if any)

Traceback (most recent call last):
  File "tiktok.py", line 16, in <module>
    api = TikTokApi.get_instance(use_selenium=True)
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 89, in get_instance
    TikTokApi(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 56, in __init__
    self.browser = browser(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/browser_selenium.py", line 68, in __init__
    self.setup_browser()
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/browser_selenium.py", line 78, in setup_browser
    fix_hairline=True,
  File "/usr/local/lib/python3.7/site-packages/selenium_stealth/__init__.py", line 45, in stealth
    with_utils(driver, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/selenium_stealth/utils.py", line 8, in with_utils
    driver, Path(__file__).parent.joinpath("js/utils.js").read_text()
  File "/usr/local/lib/python3.7/site-packages/selenium_stealth/wrapper.py", line 20, in evaluateOnNewDocument
    "source": js_code,
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 145, in execute_cdp_cmd
    return self.execute("executeCdpCommand", {'cmd': cmd, 'params': cmd_args})['value']
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 208, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: unknown command: session/aa34d8a58204a35cc98b6825c9dfbf6e/goog/cdp/execute
Traceback (most recent call last):
  File "tiktok.py", line 15, in <module>
    api = TikTokApi.get_instance()
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 89, in get_instance
    TikTokApi(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 56, in __init__
    self.browser = browser(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/browser.py", line 82, in __init__
    raise e
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/browser.py", line 78, in __init__
    self.browser = get_playwright().webkit.launch(
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/browser.py", line 26, in get_playwright
    raise e
  File "/usr/local/lib/python3.7/site-packages/TikTokApi/browser.py", line 24, in get_playwright
    playwright = sync_playwright().start()
  File "/usr/local/lib/python3.7/site-packages/playwright/__init__.py", line 34, in sync_playwright
    return SyncPlaywrightContextManager()
  File "/usr/local/lib/python3.7/site-packages/playwright/main.py", line 81, in __init__
    self._connection = run_driver()
  File "/usr/local/lib/python3.7/site-packages/playwright/main.py", line 76, in run_driver
    return loop.run_until_complete(run_driver_async())
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.7/site-packages/playwright/main.py", line 62, in run_driver_async
    limit=32768,
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/subprocess.py", line 217, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 1544, in subprocess_exec
    bufsize, **kwargs)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/unix_events.py", line 190, in _make_subprocess_transport
    **kwargs)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_subprocess.py", line 37, in __init__
    stderr=stderr, bufsize=bufsize, **kwargs)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/unix_events.py", line 775, in _start
    universal_newlines=False, bufsize=bufsize, **kwargs)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.7/site-packages/playwright/driver/playwright-cli': '/usr/local/lib/python3.7/site-packages/playwright/driver/playwright-cli'

Desktop (please complete the following information):

  • OS: MacOS
  • TikTokApi Version - 3.8.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
davidteathercommented, Dec 8, 2020

They’re used to sign a request url. You can use an external_signer though check examples for mroe info

0reactions
thevenkrishcommented, Dec 25, 2020

Seems like an os version

Selenium Issue seems like I messed up selenium implementation of adding args in the code but theoretically when I fix this you could try TikTokApi.get_instance(args=['----start-maximized])

Playwright Issue

You could try to use the Dockerfile if you’re unable to resolve this issue that should hopefully work for you.

is the selenium issue fixed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Web Automation: Don't Use Selenium, Use Playwright : r/Python
As far as I know, webdrivers for Selenium are maintained by the browser vendors directly, but Playwright is unlikely to have such support....
Read more >
Web automation: Don't use Selenium, use Playwright
Yes! Recording xpath works fine in many cases, but once something on the website changes you are left with this auto-generated Xpath that...
Read more >
Selenium and Playwright Visibility Checks: Why do they fail ...
Checking element visibility might seem simple, “It's just on the page!”. However, there are several issues with visibility checks. Why… By ...
Read more >
Can a website detect when you are using Selenium with ...
Basically, the way the Selenium detection works, is that they test for predefined JavaScript variables which appear when running with Selenium.
Read more >
Handle pop-ups, permissions, and notifications - BrowserStack
Enable or disable pop-ups in Chrome, IE, Edge, and Safari during Selenium tests on BrowserStack ... To enable the pop-ups in IE, use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found