我想使用selenium和phantomjs生成屏幕截图。这是我从virtualenv(Python 2.7,Windows 8)执行的代码:
from selenium import webdriver
br = webdriver.PhantomJS(executable_path='C:\phantomjs\phantomjs.exe')
br.set_window_size(1376,768)
br.get('http://www.stackoverflow.com')
br.save_screenshot('screenshot.png')
br.quit()
但是我收到了这个错误:
Traceback (most recent call last):
File "C:\bunker\Lib\site-packages\custom_scn.py", line 58, in <module>
br = webdriver.PhantomJS(executable_path='C:\phantomjs\phantomjs.exe')
File "C:\bunker\Lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 49, in __init__
service_args=service_args,log_path=service_log_path)
TypeError: __init__() got an unexpected keyword argument 'log_path'
PhantomJs
位于路径C:\phantomjs\phantomjs.exe
。如何进行调试:(
答案 0 :(得分:0)
尝试将log_path的值设置为:
log_path = os.devnull