0

I'm a beginner in Python and Selenium, and I dont know what is the error in my code or environment...

# encoding: utf-8
import time
from selenium import webdriver
from bs4 import BeautifulSoup

driver = webdriver.Chrome(executable_path=r'C:/Python27/Scripts/chromedriver') 
time.sleep(3)
driver.get('https://www.google.com.tw/')   
for i in range(10):  
    driver.execute_script('window.scrollTo(0, document.body.scrollHeight);')  
    time.sleep(1)  
    print ("Scrolling...")
driver.close()  

And here is error messages...

C:\Python27\python.exe D:/PythonPratice/test.py Traceback (most recent call last): File "D:/PythonPratice/test.py", line 9, in driver.get('https://www.google.com.tw/') File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 250, in get self.execute(Command.GET, {'url': url}) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 238, in execute self.error_handler.check_response(response) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"2172.1","isDefault":true},"id":1,"name":"","origin":"://"} (Session info: chrome=56.0.2924.87) (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)

Process finished with exit code 1

Much thanks!

2 Answers 2

1

Try to download latest version of chromedriver and put it to C:/Python27/Scripts/ instead of outdated one

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks ur answer, but I cannot download it from this site.... Is this my problem?
1

you should provide full path of chromedriver.exe, see the following:

driver = webdriver.Chrome(executable_path=r'C:/Python27/Scripts/chromedriver.exe') 

4 Comments

no need to provide the path explicitly if chromedriver is located somewhere on your system path
source code is saying - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH, check github.com/SeleniumHQ/selenium/blob/…
that's what my comment said
thanks for reminding, chrome path is given explicitly in the original question thats why I recommended this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.