remove singletonlock if using headless

singletonlock file prevents reusing a profile when in headless mode
This commit is contained in:
Michael Oliver 2023-08-24 10:03:25 -07:00 committed by GitHub
parent a415e40b0b
commit b90dc33754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -294,6 +294,11 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
if user_data_dir: if user_data_dir:
options.add_argument("--user-data-dir=%s" % user_data_dir) options.add_argument("--user-data-dir=%s" % user_data_dir)
singleton_lock_file = f"{user_data_dir}/SingletonLock"
if headless and os.path.islink(singleton_lock_file):
logger.info("Removing SingletonLock %s in order to reuse existing headless profile" % singleton_lock_file)
os.remove(singleton_lock_file)
language, keep_user_data_dir = None, bool(user_data_dir) language, keep_user_data_dir = None, bool(user_data_dir)