示例代码:
public void submitFocusAreaRect(final Camera.Area focusArea)
{
if (mCameraParameters.getMaxNumFocusAreas() == 0) { return; }
// Submit focus area to camera
ArrayList<Camera.Area> focusAreas = new ArrayList<Camera.Area>();
//focusAreas.add(focusArea);
focusAreas.add(new Camera.Area(new Rect(0, -1000, 1000, 1000), 1000));
mCameraParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
mCameraParameters.setFocusAreas(focusAreas);
mCamera.setParameters(mCameraParameters);
// Start the autofocus operation
mCamera.autoFocus(new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean success, Camera camera) {
mCamera.cancelAutoFocus();
}
});
}
返回以下异常:
from selenium import webdriver
browser = webdriver.Chrome()
browser.minimize_window()
添加行
File "myScript.py", line 4, in <module>
browser.minimize_window()
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 738, in minimize_window
self.execute(Command.MINIMIZE_WINDOW)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 208, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: unknown command: session/8252be05ea571a2c623450db8ba097c0/window/minimize
表明print dir(browser)
是浏览器列出的功能。那有什么呢?此功能是否仅与Chrome不兼容?
Python 2.7
答案 0 :(得分:1)
此错误消息...
selenium.common.exceptions.WebDriverException: Message: unknown command: session/8252be05ea571a2c623450db8ba097c0/window/minimize
...表示未重新调用 minimize_window()函数的调用。
您发现它是正确的。由于现在 WebDriver规范是 W3C建议,用于最大化 的功能定义根据 W3C推荐规范进行了调整>如下:
def maximize_window(self):
"""
Maximizes the current window that webdriver is using
"""
params = None
command = Command.W3C_MAXIMIZE_WINDOW
if not self.w3c:
command = Command.MAXIMIZE_WINDOW
params = {'windowHandle': 'current'}
self.execute(command, params)
但是,最小化窗口的功能定义仍在 Python客户端中与 W3C 兼容,这仍然定义为:
def minimize_window(self):
"""
Invokes the window manager-specific 'minimize' operation
"""
self.execute(Command.MINIMIZE_WINDOW)
因此您会看到错误 unknown command: session/8252be05ea571a2c623450db8ba097c0/window/minimize
答案 1 :(得分:0)
只需尝试将我的chromedriver
版本降级到2.25并得到...
selenium.common.exceptions.WebDriverException:消息:未知命令:session / f35727d2129895c35b24deeb7090eb26 / window / minimize
具有相同的代码。
但是如果使用最后一个(2.43),它就可以正常工作
因此,只需升级到最新的chromedriver
版本即可使用minimize_window
方法