python初心者です。よろしくお願いいたします
chromedriverを使用、ログイン状態を維持し画面遷移を行いたいのですが、
googleページが開いたあと、yahooページへ遷移しません。
どのように改善すればよろしいでしょうか?
from selenium import webdriver
import time
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=/Users/imac/Library/Application Support/Google/Chrome")
w = webdriver.Chrome(executable_path="/usr/local/bin/chromedriver", chrome_options=options)
driver = webdriver.Chrome()
driver.get("https://www.yahoo.co.jp")
上記プログラムを実行するとログイン済みのgoogleページが表示されますが、Yahoo!へ遷移がされません。
プログラム最後の2行がうまく働いていない状態です。
上記プログラムを参考にしたサイトはこちらです
https://qiita.com/yusukebkk/items/3fbe157ec2342d98d9fd
python環境を整えるために参考にしたサイトはこちらです
https://prog-8.com/docs/python-env
表示されるエラーログはこちらです
Traceback (most recent call last):
File "test.py", line 6, in <module>
w = webdriver.Chrome(executable_path="/usr/local/bin/chromedriver", chrome_options=options)
File "/Users/imac/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in init
desired_capabilities=desired_capabilities)
File "/Users/imac/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in init
self.start_session(capabilities, browser_profile)
File "/Users/imac/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/Users/imac/.pyenv/versions/3.6.5/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/Users/imac/.pyenv/versions/3.6.5/lib/python3.6/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: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /Applications/Google Chrome.app/Contents/MacOS/Google Chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Mac OS X 10.14.2 x86_64)
回答1件
あなたの回答
tips
プレビュー