After switching to ChromeDriverManager().install(),I am not able to use default profile.Any workaround there so that I can avoid logging in every time?
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),....)
used many solutions found here, but still not working.
directories:
user-data-dir=C:\Users\xxx\AppData\Local\Google\Chrome\User Data
user-data-dir=C:\Users\xxx\AppData\Local\Google\Chrome\User Data\Default
To use the default profile, you have to mention the path like below:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
options = Options()
# path of the chrome profile's parent directory
options.add_argument(r"user-data-dir=C:\\Users\\User\\AppData\\Local\\Google\\Chrome\\User Data")
# name of the directory
options.add_argument("--profile-directory=Default")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
Related
I need my cookies to be accepted and used after logging in, and to be checked for validity and, if not valid, to be updated again when I start the program.
The site is https://web.telegram.org/
How do I do this?
I found a kind of cookie authorization checker.
The link is https://telegram.me/_websync_?authed=1&version=1.7.1%20K
I don't understand how to do it.
My code:
import requests
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
driver = webdriver.Chrome(options=options, service=Service(ChromeDriverManager().install()))
driver.maximize_window()
driver.get('https://web.telegram.org/k/##MOWALY')
I don't see how it can be done.
I want to add a chrome extension from 2Captcha to my python selenium bot but it doesn't work.
Download the extension: https://chrome.google.com/webstore/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo/related?hl=en
and then in Python:
from selenium.webdriver import ChromeOptions, Chrome
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = ChromeOptions()
options.add_argument(f'--load-extension=C:\Users\Administrator\AppData\Local\Google\Chrome\User Data\Default\Extensions\ifibfemgeogfhoebkmokieepdoobkbpo\3.2.1_0')
driver = Chrome(service = Service(ChromeDriverManager().install()), options = options)
Can't you just add any extension?
I'm trying to launch some browser (Chrome) functions by sending shortcuts
I have tried several methods but they all cannot work.
I do this by following these steps
Initialize the browser
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
options = Options()
options.add_argument("--user-data-dir="+r"path_to_user_data")
options.add_experimental_option("excludeSwitches", ["enable-logging"])
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())
,options=options
)
Through actionchain
ActionChains(driver).key_down(Keys.CONTROL).key_down('T').key_up('T').key_up(Keys.CONTROL).perform
Through send_key
driver.find_element(by=By.XPATH,value="/html/body").send_keys(Keys.CONTROL+"T")
But it doesn't work. This is confused for me. Why it cannot work?
It is possible to open a new tab and switch to it with a single command
driver.switch_to.new_window()
To Open a blank new tab you can use the below:
driver.execute_script("window.open('');")
Switch to the new window
driver.switch_to.window(driver.window_handles[1])
I will do a project by using selenium. But there is a problem for me. I have to use chrome with my settings. My websites login, my history...
But when I use the selenium, It creates a new chrome browser that with a default settings. No Websites login here and others.
My code:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
driver =webdriver.Chrome(ChromeDriverManager().install())
How can i use my current chrome settings or how can I change webdriver by location.
For example(maybe):
driver =webdriver.Chrome(location="C\\Users\\Desktop\\chrome.exe)
I fix my problem with this way:
from selenium import webdriver
import time
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\Fatih\\AppData\\Local\\Google\\Chrome\\User Data")
options.add_argument('--profile-directory=Default')
driver = webdriver.Chrome(executable_path="chromedriver.exe", options=options)
my "chromedriver.exe" is in same path with my python files.
I am trying to add a chrome profile into my program, but it is not doing anything. Can someone please help?
I am using Selenium python. When I run it seems to ignore the statements and runs in a temp profile.
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import random
import string
from selenium.webdriver.chrome.options import Options
while True:
emailstarter = random.randint(11111111111111111111,999999999999999999999)
first = random.randint(666666,888888)
last = random.randint(555,55555)
driver = webdriver.Chrome(r"C:\Program Files (x86)\chromedriver.exe") # Optional argument, if not specified will search path.
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data\\Default");
You have the order wrong. You should create the options first and then pass them as an argument to the webdriver.Chrome class:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data\\Default");
driver = webdriver.Chrome(
executable_path=r"C:\Program Files (x86)\chromedriver.exe",
options=options
)