2017-04-19 2 views
0

これは私が試したコードです、私は別のstackoverflowページから取得し、それは動作しませんでした。なぜどんなアイデア?要素からのpythonセレンセービングスクリーンショット

chrome = webdriver.Chrome() 
chrome.get('http://stackoverflow.com/') 

# now that we have the preliminary stuff out of the way time to get that image :D 
element = chrome.find_element_by_class_name('-img') # find part of the page you want image of 
location = element.location 
size = element.size 
chrome.save_screenshot('screenshot.png') # saves screenshot of entire page 
chrome.quit() 

raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html (Session info: chrome=57.0.2987.133) (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.10586 x86_64)

編集:

from selenium import webdriver 
from selenium.webdriver.chrome.options import Options 


chrome_options = Options() 
chrome_options.add_argument("--disable-extensions") 
chrome = webdriver.Chrome(chrome_options=chrome_options) 

chrome.get('http://stackoverflow.com/') 

# now that we have the preliminary stuff out of the way time to get that image :D 
element = chrome.find_element_by_class_name('-img') # find part of the page you want image of 
location = element.location 
size = element.size 
chrome.save_screenshot('screenshot.png') # saves screenshot of entire page 
chrome.quit() 
をしようとしましたエラー:

raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html (Session info: chrome=57.0.2987.133) (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.10586 x86_64)

+0

更新クロームドライバのためのスクリーンショットをキャプチャしますelement.save_screenshot("file name")を呼び出す

にこれを行う方法を提供してきました –

答えて

0

あなたのchromedriverを更新する必要があります。私はあなたのクロムドライバーが古いと思う。

あなたの質問に基づいて、あなたは要素をスクリーンショットしたいと思いますが、現在、セレンはちょうどそれが特定の要素

関連する問題