Skip to content

Commit dedc1ee

Browse files
committed
moved FindElement implementation to base class
1 parent f4a3539 commit dedc1ee

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

inc/extension_qt/q_view_executor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class QViewCmdExecutor : public ViewCmdExecutor {
3838
virtual void SendKeys(const string16& keys, Error** error);
3939
virtual void Close(Error** error);
4040
virtual void SwitchTo(Error** error);
41+
virtual void FindElement(const ElementId& root_element, const std::string& locator, const std::string& query, ElementId* element, Error** error);
4142
virtual void GetAlertMessage(std::string* text, Error** error);
4243
virtual void SetAlertPromptText(const std::string& alert_prompt_text, Error** error);
4344
virtual void AcceptOrDismissAlert(bool accept, Error** error);

inc/extension_qt/widget_view_executor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class QWidgetViewCmdExecutor : public QViewCmdExecutor {
6060
virtual void ElementSubmit(const ElementId& element, Error** error) NOT_SUPPORTED_IMPL;
6161
virtual void GetElementText(const ElementId& element, std::string* element_text, Error** error);
6262
virtual void GetElementCssProperty(const ElementId& element, const std::string& property, base::Value** value, Error** error) NOT_SUPPORTED_IMPL;
63-
virtual void FindElement(const ElementId& root_element, const std::string& locator, const std::string& query, ElementId* element, Error** error);
6463
virtual void FindElements(const ElementId& root_element, const std::string& locator, const std::string& query, std::vector<ElementId>* elements, Error** error);
6564
virtual void ActiveElement(ElementId* element, Error** error);
6665
virtual void SwitchToFrameWithNameOrId(const std::string& name_or_id, Error** error) NOT_SUPPORTED_IMPL;

src/webdriver/extension_qt/q_view_executor.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ void QViewCmdExecutor::SetBounds(const Rect& bounds, Error** error) {
7575
if (NULL == view)
7676
return;
7777

78+
if (!view->isTopLevel()) {
79+
*error = new Error(kUnknownError, "Cant set bounds to non top level view.");
80+
return;
81+
}
82+
7883
view->setGeometry(ConvertRectToQRect(bounds));
7984
}
8085

@@ -185,6 +190,15 @@ void QViewCmdExecutor::SwitchTo(Error** error) {
185190
session_->logger().Log(kInfoLogLevel, "SwitchTo - set current view ("+view_id_.id()+")");
186191
}
187192

193+
void QViewCmdExecutor::FindElement(const ElementId& root_element, const std::string& locator, const std::string& query, ElementId* element, Error** error) {
194+
std::vector<ElementId> elements;
195+
FindElements(root_element, locator, query, &elements, error);
196+
if (*error == NULL && !elements.empty())
197+
*element = elements[0];
198+
else if(*error == NULL)
199+
*error = new Error(kNoSuchElement);
200+
}
201+
188202
void QViewCmdExecutor::GetAlertMessage(std::string* text, Error** error) {
189203
QWidget* view = getView(view_id_, error);
190204
if (NULL == view)

src/webdriver/extension_qt/widget_view_executor.cc

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -717,19 +717,6 @@ void QWidgetViewCmdExecutor::GetElementText(const ElementId& element, std::strin
717717
*error = new Error(kNoSuchElement);
718718
}
719719

720-
void QWidgetViewCmdExecutor::FindElement(const ElementId& root_element, const std::string& locator, const std::string& query, ElementId* element, Error** error) {
721-
QWidget* view = getView(view_id_, error);
722-
if (NULL == view)
723-
return;
724-
725-
std::vector<ElementId> elements;
726-
FindElements(root_element, locator, query, &elements, error);
727-
if (*error == NULL && elements.size() != 0)
728-
*element = elements[0];
729-
else if(*error == NULL)
730-
*error = new Error(kNoSuchElement);
731-
}
732-
733720
void QWidgetViewCmdExecutor::FindElements(const ElementId& root_element, const std::string& locator, const std::string& query, std::vector<ElementId>* elements, Error** error) {
734721
QWidget* view = getView(view_id_, error);
735722
if (NULL == view)

0 commit comments

Comments
 (0)