This question already has answers here:
How to connect to Tor browser using Python
(3 answers)
How to use Tor with Chrome browser through Selenium
(2 answers)
Closed 6 days ago.
I'm wondering if anyone can explain, why the lines come after service.start() do not execute?
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
import time
tor_path = "Browser"
service = FirefoxService(executable_path=tor_path + "/firefox.exe")
print(service.service_url)
service.start()
driver = webdriver.Firefox(service.service_url)
print("after time")
time.sleep(20)
driver.get("https://www.google.com")
Related
This question already has answers here:
How to save login data to be recognized for Python Selenium webdriver
(2 answers)
Error when loading cookies into a Python request session
(6 answers)
Closed 2 years ago.
import pickle
import selenium
from selenium import webdriver
import selenium.webdriver
import options
path = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(path)
chrome_options = Options()
chrome_options.add_argument("user-data-dir=selenium")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get("http://www.google.com")
the error that i am getting is: NameError: name 'Options' is not defined
am i doing soomething tottaly wrong. im trying to save the cookies so that next time i can login in to my whatsapp without having to manualy do the qr code
This question already has answers here:
Can a website detect when you are using Selenium with chromedriver?
(25 answers)
How to find the $cdc_ (chromedriver params) in website?
(1 answer)
Selenium Webdriver can't access a website (The requested URL was rejected)
(1 answer)
Closed 2 years ago.
i am facing an issue that i hope anyone can help me with.
i'm trying to scrape a webpage using selenium package on python but it keeps detecting that i'm using selenium and redirects me to a log in page that i can't use.
i tried using a fake agent but it still detected me, i tried changing the "$cdc" in the chrome driver but it still didn't work. apperciate if anyone can help me.
here is the code i'm using :
options = webdriver.ChromeOptions()
ua = UserAgent()
userAgent = ua.random
options.add_argument('--ignore-certificate-errors')
options.add_argument('--incognito')
options.add_argument("--window-size=1920,1080")
options.add_argument('enable-automation')
options.add_argument(f'user-agent={userAgent}')
#options.add_argument('--headless')
driver = webdriver.Chrome()
driver.get("https://www.mcmaster.com/nuts/hex-nuts/medium-strength-steel-hex-nuts-grade-5/")
This question already has answers here:
How to make Firefox headless programmatically in Selenium with Python?
(7 answers)
Closed 2 years ago.
I have this code:
from selenium import webdriver
driver = webdriver.Firefox()
But how can I let the browser open up minimized or hidden?
The headless property will do the task for you. Import Options() from selenium.webdriver.firefox.options
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
my_opt = Options()
my_opt.headless = True
driver = webdriver.Firefox(options=my_opt, executable_path=r'path_to_your_geckodriver')
driver.get("url_you_want_to_access")
All set!
This question already has answers here:
Selenium: Point towards default Chrome session
(2 answers)
How to open a Chrome Profile through --user-data-dir argument of Selenium
(3 answers)
How to use Chrome Profile in Selenium Webdriver Python 3
(12 answers)
Closed 3 years ago.
So thats my code, I want to open chrome with my default profile information in selenium. but its doesn't load and crashes when I click on profile icon in chrome
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=/Users/Library/Application Support/Google/Chrome/Default/Default")
driver = webdriver.Chrome(executable_path='/Users/Desktop/supbot/chromedriver', options=options, service_log_path="/tmp/log")
driver.get('google.com')
You should use full path to the driver file like:
C:\pathtodriver\chromedriver.exe
Also, avoid using Capabilities, try this approach:
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get('google.com')
This question already has answers here:
unknown error: DevToolsActivePort file doesn't exist error while executing Selenium UI test cases on ubuntu
(15 answers)
org.openqa.selenium.WebDriverException: chrome not reachable - when attempting to start a new session
(1 answer)
Closed 3 years ago.
I have two different cases of problems.
Basically, when I run the code with python in terminal on rasberrypie3, it works well.
But when I try to run with cron, it doesn't work.
1st case : don,t use headless chromium-browser.
2nd case : use headless chromium-browser.
#1st case
from selenium import webdriver
from time import sleep
options = webdriver.ChromeOptions()
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
#options.add_argument("--headless")
driver = webdriver.Chrome('chromedriver',options=options)
driver.get('target_url')
driver.find_element_by_name('id').send_keys(some_id)
driver.quit()
#2nd case
from selenium import webdriver
from time import sleep
options = webdriver.ChromeOptions()
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--headless")
driver = webdriver.Chrome('chromedriver',options=options)
driver.get('target_url')
driver.find_element_by_name('id').send_keys(some_id)
driver.quit()
I expect that 'some_id' put in the id box.
But 1st case => unknown error : DevToolActivePort file doesn't exist
2nd case => selenium.common.exceptions.WebDriverException: Message: Chrome not reachable