-
Notifications
You must be signed in to change notification settings - Fork 1.4k
-
If you look at the following simple code:
from seleniumbase import Driver
import time
user_data_dir = r"C:\Users\markh\AppData\Local\Google\Chrome\User Data"
driver = Driver(uc=True, user_data_dir=user_data_dir)
try:
driver.get("https://www.tiktok.com")
time.sleep(10)
finally:
# Always close the browser when done
driver.quit()
Tiktok will always run whne I don't pass the user data in but when I start passing hte user data such that I'm logged in as a profile, tiktok or any other site for that matter refuse to load
Beta Was this translation helpful? Give feedback.
All reactions
You can't mix a UC Mode user_data_dir
with one that was used by a regular Chrome instance. The formats are different.
Have UC Mode create a new user_data_dir during the script run, and then you can call the script again with the same one.
Here's an example of a script that goes to TikTok while setting a custom user_data_dir
:
from seleniumbase import SB with SB(uc=True, test=True, ad_block=True, user_data_dir="my_dir") as sb: url = "https://www.tiktok.com/@startrek?lang=en" sb.activate_cdp_mode(url) sb.sleep(2) print(sb.get_text('h2[data-e2e="user-bio"]')) for i in range(54): sb.cdp.scroll_down(12) sb.sleep(1)
Replies: 1 comment 4 replies
-
You can't mix a UC Mode user_data_dir
with one that was used by a regular Chrome instance. The formats are different.
Have UC Mode create a new user_data_dir during the script run, and then you can call the script again with the same one.
Here's an example of a script that goes to TikTok while setting a custom user_data_dir
:
from seleniumbase import SB with SB(uc=True, test=True, ad_block=True, user_data_dir="my_dir") as sb: url = "https://www.tiktok.com/@startrek?lang=en" sb.activate_cdp_mode(url) sb.sleep(2) print(sb.get_text('h2[data-e2e="user-bio"]')) for i in range(54): sb.cdp.scroll_down(12) sb.sleep(1)
Beta Was this translation helpful? Give feedback.
All reactions
-
This didn't work. I threw print statements inside of the with block and none of them ever printed. I was able to get chrome to open with the correct account signed in but it never navigated to tiktok
Beta Was this translation helpful? Give feedback.
All reactions
-
There would be a stack trace if it didn't reach the print()
statements inside the with
block.
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.
All reactions
-
You can't mix a UC Mode user_data_dir
with one that was used by a regular Chrome instance. The formats are different. I can see you're setting the user_data_dir
to the one from your regular Chrome browser.
Beta Was this translation helpful? Give feedback.