Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Selenium driver.get() does not work
#1
It seems very simple but I am new to python and I'm stumped as to why this won't work.
from selenium import webdriver

class my_class(object):
    chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'
    driver = webdriver.Chrome(chrome_path)
    driver.get('https://google.com')
I am following: https://selenium-python.readthedocs.io/g...arted.html

yet the first thing I try does not work.

All it does is open a new window with chrome. It does not load google.

Any help appreciated :)
Quote
#2
You need to download and use the chrome driver
https://sites.google.com/a/chromium.org/.../downloads
Quote
#3
(Dec-14-2018, 04:39 AM)metulburr Wrote: You need to download and use the chrome driver
https://sites.google.com/a/chromium.org/.../downloads

Okay thanks, do you happen to know how to import my login credentials and what not?

from selenium import webdriver

class my_class(object):
    # set chromes path
    chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chromedriver.exe'
    ## login stuff
    #web = Browser()
    driver = webdriver.Chrome(chrome_path)
    options = webdriver.ChromeOptions()
    options.add_argument('user-data-dir=C:/Users/tom/AppData/Local/Google/Chrome/User Data')
Something like that I suppose.

Thanks

(Dec-14-2018, 04:48 AM)RvBVakama Wrote:
(Dec-14-2018, 04:39 AM)metulburr Wrote: You need to download and use the chrome driver
https://sites.google.com/a/chromium.org/.../downloads

Okay thanks, do you happen to know how to import my login credentials and what not?

from selenium import webdriver

class my_class(object):
    # set chromes path
    chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chromedriver.exe'
    ## login stuff
    #web = Browser()
    driver = webdriver.Chrome(chrome_path)
    options = webdriver.ChromeOptions()
    options.add_argument('user-data-dir=C:/Users/tom/AppData/Local/Google/Chrome/User Data')
Something like that I suppose.

Thanks

from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_argument("user-data-dir=C:\\Users\\RvBVakama\\AppData\\Local\\Google\\Chrome\\User Data") #Path to your chrome profile
w = webdriver.Chrome(executable_path="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe", chrome_options=options)
w.get("http://google.com")


Got it working but now it won't get() again

This is the error I get


[13620:13324:1214/160750.819:ERROR:cache_util_win.cc(19)] Unable to move the cache: 5
[13620:13324:1214/160750.819:ERROR:cache_util.cc(140)] Unable to move cache folder C:\Users\RvBVakama\AppData\Local\Google\Chrome\User Data\ShaderCache\GPUCache to C:\Users\RvBVakama\AppData\Local\Google\Chrome\User Data\ShaderCache\old_GPUCache_000
[13620:13324:1214/160750.820:ERROR:disk_cache.cc(168)] Unable to create cache
[13620:13324:1214/160750.821:ERROR:shader_disk_cache.cc(620)] Shader Cache Creation failed: -2
Traceback (most recent call last):
File "tet2.py", line 5, in <module>
w = webdriver.Chrome(executable_path="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe", chrome_options=options)
File "C:\Users\RvBVakama\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "C:\Users\RvBVakama\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\RvBVakama\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\RvBVakama\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\RvBVakama\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 6.1.7601 SP1 x86_64)

SOLVED
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python-selenium script for automated web-login does not work hectorKJ 2 729 Sep-10-2019, 01:29 PM
Last Post: buran
  Selenium Web Driver Exe not running in other PC's Utkarsh29 2 1,071 Feb-28-2019, 05:48 PM
Last Post: snippsat
  Proxy Variable in Selenium wont work with FireFox Profile Proxy Setting. MIPython 0 5,187 Jul-13-2018, 05:43 PM
Last Post: MIPython
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 1,206 Nov-03-2017, 08:41 PM
Last Post: metulburr
  Selenium chrome driver not returning solution Prince_Bhatia 0 1,649 Jul-06-2017, 06:40 AM
Last Post: Prince_Bhatia

Forum Jump:


Users browsing this thread: 1 Guest(s)