-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated IE driver to better support W3C WebDriver Specification
This is a large update that includes implementation of the following things that are part of the WebDriver spec: * Implement the "get element property" command * Implement the "get named cookie" command * Implement the "minimize window" command * Implement the "fullscreen window" command * Update "set window rect" command to correctly recognize and restore from minimized or full screen state * Fix the "release actions" command to properly roll back all pending actions * Update the "perform actions" command to be more robust for pointer actions * Fix alert handling to handle dialogs with the "Do not show any more dialogs" check box * Added handling for the "dismiss and notify" and "accept and notify" user prompt handler states
- Loading branch information
Showing
44 changed files
with
1,274 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
cpp/iedriver/CommandHandlers/FullScreenWindowCommandHandler.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "FullScreenWindowCommandHandler.h" | ||
#include "errorcodes.h" | ||
#include "logging.h" | ||
#include "../Browser.h" | ||
#include "../IECommandExecutor.h" | ||
#include "../Script.h" | ||
|
||
namespace webdriver { | ||
|
||
FullScreenWindowCommandHandler::FullScreenWindowCommandHandler(void) { | ||
} | ||
|
||
FullScreenWindowCommandHandler::~FullScreenWindowCommandHandler(void) { | ||
} | ||
|
||
void FullScreenWindowCommandHandler::ExecuteInternal( | ||
const IECommandExecutor& executor, | ||
const ParametersMap& command_parameters, | ||
Response* response) { | ||
int status_code = WD_SUCCESS; | ||
|
||
BrowserHandle browser_wrapper; | ||
status_code = executor.GetCurrentBrowser(&browser_wrapper); | ||
if (status_code != WD_SUCCESS) { | ||
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Error retrieving window"); | ||
return; | ||
} | ||
|
||
bool supports_full_screen = browser_wrapper->SetFullScreen(true); | ||
if (!supports_full_screen) { | ||
response->SetErrorResponse(ERROR_UNSUPPORTED_OPERATION, | ||
"This version of Internet Explorer does not support setting to full screen"); | ||
} | ||
|
||
HWND window_handle = browser_wrapper->GetTopLevelWindowHandle(); | ||
RECT window_rect; | ||
::GetWindowRect(window_handle, &window_rect); | ||
Json::Value response_value; | ||
response_value["width"] = window_rect.right - window_rect.left; | ||
response_value["height"] = window_rect.bottom - window_rect.top; | ||
response_value["x"] = window_rect.left; | ||
response_value["y"] = window_rect.top; | ||
response->SetSuccessResponse(response_value); | ||
} | ||
|
||
} // namespace webdriver |
36 changes: 36 additions & 0 deletions
36
cpp/iedriver/CommandHandlers/FullScreenWindowCommandHandler.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
#ifndef WEBDRIVER_IE_FULLSCREENWINDOWCOMMANDHANDLER_H_ | ||
#define WEBDRIVER_IE_FULLSCREENWINDOWCOMMANDHANDLER_H_ | ||
|
||
#include "../IECommandHandler.h" | ||
|
||
namespace webdriver { | ||
|
||
class FullScreenWindowCommandHandler : public IECommandHandler { | ||
public: | ||
FullScreenWindowCommandHandler(void); | ||
virtual ~FullScreenWindowCommandHandler(void); | ||
|
||
protected: | ||
void ExecuteInternal(const IECommandExecutor& executor, | ||
const ParametersMap& command_parameters, | ||
Response* response); | ||
}; | ||
|
||
} // namespace webdriver | ||
|
||
#endif // WEBDRIVER_IE_FULLSCREENWINDOWCOMMANDHANDLER_H_ |
81 changes: 81 additions & 0 deletions
81
cpp/iedriver/CommandHandlers/GetElementPropertyCommandHandler.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "GetElementPropertyCommandHandler.h" | ||
#include "errorcodes.h" | ||
#include "../Browser.h" | ||
#include "../Element.h" | ||
#include "../IECommandExecutor.h" | ||
|
||
namespace webdriver { | ||
|
||
GetElementPropertyCommandHandler::GetElementPropertyCommandHandler(void) { | ||
} | ||
|
||
GetElementPropertyCommandHandler::~GetElementPropertyCommandHandler(void) { | ||
} | ||
|
||
void GetElementPropertyCommandHandler::ExecuteInternal( | ||
const IECommandExecutor& executor, | ||
const ParametersMap& command_parameters, | ||
Response* response) { | ||
ParametersMap::const_iterator id_parameter_iterator = command_parameters.find("id"); | ||
ParametersMap::const_iterator name_parameter_iterator = command_parameters.find("name"); | ||
if (id_parameter_iterator == command_parameters.end()) { | ||
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter in URL: id"); | ||
return; | ||
} else if (name_parameter_iterator == command_parameters.end()) { | ||
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter in URL: name"); | ||
return; | ||
} else { | ||
std::string element_id = id_parameter_iterator->second.asString(); | ||
std::string name = name_parameter_iterator->second.asString(); | ||
|
||
BrowserHandle browser_wrapper; | ||
int status_code = executor.GetCurrentBrowser(&browser_wrapper); | ||
if (status_code != WD_SUCCESS) { | ||
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Unable to get browser"); | ||
return; | ||
} | ||
|
||
ElementHandle element_wrapper; | ||
status_code = this->GetElement(executor, element_id, &element_wrapper); | ||
if (status_code == WD_SUCCESS) { | ||
std::string value = ""; | ||
bool is_null; | ||
status_code = element_wrapper->GetPropertyValue(name, | ||
&value, | ||
&is_null); | ||
if (status_code != WD_SUCCESS) { | ||
response->SetErrorResponse(status_code, "Unable to get property"); | ||
return; | ||
} else { | ||
if (is_null) { | ||
response->SetSuccessResponse(Json::Value::null); | ||
return; | ||
} else { | ||
response->SetSuccessResponse(value); | ||
return; | ||
} | ||
} | ||
} else { | ||
response->SetErrorResponse(ERROR_STALE_ELEMENT_REFERENCE, "Element is no longer valid"); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
} // namespace webdriver |
Oops, something went wrong.