From 7083138b0d8745e4e2a39f8fff93a92d1dbf7852 Mon Sep 17 00:00:00 2001 From: Tatiana Buldina Date: Mon, 17 Sep 2018 23:22:01 +0000 Subject: [PATCH] [ChromeDriver] Make ExecuteSwitchToFrame() W3C compliant Bug: chromedriver:1992 Change-Id: If7729d68d753459a9b27fc52d053d5f065341c24 Reviewed-on: https://chromium-review.googlesource.com/1229188 Reviewed-by: John Chen Commit-Queue: Tatiana Buldina Cr-Commit-Position: refs/heads/master@{#591868} --- chrome/test/chromedriver/element_util.cc | 16 ++++++++-------- chrome/test/chromedriver/element_util.h | 2 ++ chrome/test/chromedriver/window_commands.cc | 2 +- docs/chromedriver_status.md | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/chrome/test/chromedriver/element_util.cc b/chrome/test/chromedriver/element_util.cc index 289ce6d00e8264..4796085f07f36a 100644 --- a/chrome/test/chromedriver/element_util.cc +++ b/chrome/test/chromedriver/element_util.cc @@ -26,14 +26,6 @@ namespace { const char kElementKey[] = "ELEMENT"; const char kElementKeyW3C[] = "element-6066-11e4-a52e-4f735466cecf"; -std::string GetElementKey() { - Session* session = GetThreadLocalSession(); - if (session && session->w3c_compliant) - return kElementKeyW3C; - else - return kElementKey; -} - bool ParseFromValue(base::Value* value, WebPoint* point) { base::DictionaryValue* dict_value; if (!value->GetAsDictionary(&dict_value)) @@ -249,6 +241,14 @@ Status GetElementBorder( } // namespace +std::string GetElementKey() { + Session* session = GetThreadLocalSession(); + if (session && session->w3c_compliant) + return kElementKeyW3C; + else + return kElementKey; +} + std::unique_ptr CreateElement( const std::string& element_id) { std::unique_ptr element(new base::DictionaryValue()); diff --git a/chrome/test/chromedriver/element_util.h b/chrome/test/chromedriver/element_util.h index c273b25b0ed43b..3cf35482ac1885 100644 --- a/chrome/test/chromedriver/element_util.h +++ b/chrome/test/chromedriver/element_util.h @@ -19,6 +19,8 @@ struct Session; class Status; class WebView; +std::string GetElementKey(); + std::unique_ptr CreateElement( const std::string& element_id); diff --git a/chrome/test/chromedriver/window_commands.cc b/chrome/test/chromedriver/window_commands.cc index 3228348845b432..766a01a4dd4339 100644 --- a/chrome/test/chromedriver/window_commands.cc +++ b/chrome/test/chromedriver/window_commands.cc @@ -380,7 +380,7 @@ Status ExecuteSwitchToFrame(Session* session, const base::DictionaryValue* id_dict; if (id->GetAsDictionary(&id_dict)) { std::string element_id; - if (!id_dict->GetString("ELEMENT", &element_id)) + if (!id_dict->GetString(GetElementKey(), &element_id)) return Status(kUnknownError, "missing 'ELEMENT'"); bool is_displayed = false; Status status = IsElementDisplayed( diff --git a/docs/chromedriver_status.md b/docs/chromedriver_status.md index 3f02d2e856c81f..9f52a1e90e8002 100644 --- a/docs/chromedriver_status.md +++ b/docs/chromedriver_status.md @@ -19,7 +19,7 @@ Below is a list of all WebDriver commands and their current support in ChromeDri | DELETE | /session/{session id}/window | Close Window | Complete | | POST | /session/{session id}/window | Switch To Window | Complete | | GET | /session/{session id}/window/handles | Get Window Handles | Complete | -| POST | /session/{session id}/frame | Switch To Frame | Partially Complete | [1992](https://bugs.chromium.org/p/chromedriver/issues/detail?id=1992) +| POST | /session/{session id}/frame | Switch To Frame | Complete | | POST | /session/{session id}/frame/parent | Switch To Parent Frame | | | GET | /session/{session id}/window/rect | Get Window Rect | Complete | | POST | /session/{session id}/window/rect | Set Window Rect | Complete |