From: Hosang Kim Date: Tue, 12 Apr 2022 05:53:02 +0000 (+0900) Subject: Introduce a new FindElements command X-Git-Tag: submit/tizen/20220512.102556~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0507ad2007a4f6ef5d4a0039d8634f0fcb33d46f;p=platform%2Fcore%2Fuifw%2Faurum.git Introduce a new FindElements command Change-Id: I80e554ac877dd391437f583a44f7184f8df305d4 --- diff --git a/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h b/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h index a471ec4..119e36a 100644 --- a/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h +++ b/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h @@ -39,6 +39,10 @@ public: const ::aurum::ReqFindElement *request, ::aurum::RspFindElement *response) override; + ::grpc::Status findElements(::grpc::ServerContext *context, + const ::aurum::ReqFindElements *request, + ::aurum::RspFindElements *response) override; + ::grpc::Status getValue(::grpc::ServerContext *context, const ::aurum::ReqGetValue *request, ::aurum::RspGetValue *response) override; diff --git a/org.tizen.aurum-bootstrap/inc/Commands/Commands.h b/org.tizen.aurum-bootstrap/inc/Commands/Commands.h index c7728d5..e0badc1 100644 --- a/org.tizen.aurum-bootstrap/inc/Commands/Commands.h +++ b/org.tizen.aurum-bootstrap/inc/Commands/Commands.h @@ -17,6 +17,7 @@ #include "Commands/KillServerCommand.h" #include "Commands/FindElementCommand.h" +#include "Commands/FindElementsCommand.h" #include "Commands/GetAttributeCommand.h" #include "Commands/GetValueCommand.h" diff --git a/org.tizen.aurum-bootstrap/inc/Commands/FindElementCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/FindElementCommand.h index 1e2f3f0..01e4a21 100644 --- a/org.tizen.aurum-bootstrap/inc/Commands/FindElementCommand.h +++ b/org.tizen.aurum-bootstrap/inc/Commands/FindElementCommand.h @@ -36,5 +36,5 @@ public: ::grpc::Status execute() override; protected: virtual std::shared_ptr getSearchableTop(void); - virtual std::vector> getSelectors(void); -}; \ No newline at end of file + virtual std::shared_ptr getSelector(void); +}; diff --git a/org.tizen.aurum-bootstrap/inc/Commands/FindElementsCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/FindElementsCommand.h new file mode 100644 index 0000000..c7ea99e --- /dev/null +++ b/org.tizen.aurum-bootstrap/inc/Commands/FindElementsCommand.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed 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 +#include +#include "Commands/Command.h" +#include "ObjectMapper.h" +#include +#include "config.h" + +class FindElementsCommand : public Command { +protected: + const ::aurum::ReqFindElements *mRequest; + ::aurum::RspFindElements *mResponse; + +protected: + ObjectMapper *mObjMap; + +public: + FindElementsCommand(const ::aurum::ReqFindElements *request, + ::aurum::RspFindElements *response); + ::grpc::Status execute() override; +protected: + virtual std::shared_ptr getSearchableTop(void); + virtual std::vector> getSelectors(void); +}; diff --git a/org.tizen.aurum-bootstrap/meson.build b/org.tizen.aurum-bootstrap/meson.build index 62ebd35..0e90268 100644 --- a/org.tizen.aurum-bootstrap/meson.build +++ b/org.tizen.aurum-bootstrap/meson.build @@ -19,6 +19,7 @@ bootstrap_svr_src += [ files('src/Commands/ClickCommand.cc'), files('src/Commands/CloseAppCommand.cc'), files('src/Commands/FindElementCommand.cc'), + files('src/Commands/FindElementsCommand.cc'), files('src/Commands/FlickCommand.cc'), files('src/Commands/GetAttributeCommand.cc'), files('src/Commands/GetDeviceTimeCommand.cc'), diff --git a/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc b/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc index ea50a2b..fe62067 100644 --- a/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc +++ b/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc @@ -64,6 +64,14 @@ aurumServiceImpl::~aurumServiceImpl() return execute(cmd.get(), true); } +::grpc::Status aurumServiceImpl::aurumServiceImpl::findElements( + ::grpc::ServerContext *context, const ::aurum::ReqFindElements *request, + ::aurum::RspFindElements *response) +{ + std::unique_ptr cmd = std::make_unique(request, response); + return execute(cmd.get(), true); +} + ::grpc::Status aurumServiceImpl::aurumServiceImpl::click( ::grpc::ServerContext *context, const ::aurum::ReqClick *request, ::aurum::RspClick *response) diff --git a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc index 5e25ece..cdcdff2 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc @@ -41,7 +41,7 @@ std::shared_ptr FindElementCommand::getSearchableTop(void) return searchableObj; } -std::vector> FindElementCommand::getSelectors(void) +std::shared_ptr FindElementCommand::getSelector(void) { auto sel = std::make_shared(); @@ -66,72 +66,68 @@ std::vector> FindElementCommand::getSelectors(void) if(mRequest->_textpartialmatch_case()) sel->textPartialMatch(mRequest->textpartialmatch()); if(mRequest->_xpath_case()) sel->xpath(mRequest->xpath()); - return std::vector>{sel}; + return sel; } ::grpc::Status FindElementCommand::execute() { LOGI("findElement --------------- "); auto searchableObj = getSearchableTop(); - auto selectors = getSelectors(); + auto selector = getSelector(); + + auto found = searchableObj->findObject(selector); + + if (found != nullptr) { + UiObject *obj = found.get(); + obj->refresh(); + if (mObjMap->getElement(obj->getId()) == nullptr) + mObjMap->addElement(std::move(found)); + + LOGI("found object : %p elementId:%s", obj, obj->getId().c_str()); + + ::aurum::Element *elm = mResponse->mutable_element(); + elm->set_elementid(obj->getId()); + elm->set_package(obj->getApplicationPackage()); + + ::aurum::Rect *rect = elm->mutable_geometry(); + const Rect &size = obj->getScreenBoundingBox(); + rect->set_x(size.mTopLeft.x); + rect->set_y(size.mTopLeft.y); + rect->set_width(size.width()); + rect->set_height(size.height()); + + ::aurum::Rect *windowRect = elm->mutable_window_relative_geometry(); + const Rect &windowRelativeSize = obj->getWindowBoundingBox(); + windowRect->set_x(windowRelativeSize.mTopLeft.x); + windowRect->set_y(windowRelativeSize.mTopLeft.y); + windowRect->set_width(windowRelativeSize.width()); + windowRect->set_height(windowRelativeSize.height()); + + elm->set_widget_type(obj->getElementType()); + elm->set_widget_style(obj->getElementStyle()); + + elm->set_text(obj->getText()); + elm->set_xpath(obj->getXPath()); + elm->set_automationid(obj->getAutomationId()); + elm->set_package(obj->getApplicationPackage()); + elm->set_role(obj->getRole()); + + elm->set_ischecked(obj->isChecked()); + elm->set_ischeckable(obj->isCheckable()); + elm->set_isclickable(obj->isClickable()); + elm->set_isenabled(obj->isEnabled()); + elm->set_isfocused(obj->isFocused()); + elm->set_isfocusable(obj->isFocusable()); + elm->set_isscrollable(obj->isScrollable()); + elm->set_isselected(obj->isSelected()); + elm->set_isshowing(obj->isShowing()); + elm->set_isactive(obj->isActive()); + elm->set_isvisible(obj->isVisible()); + elm->set_isselectable(obj->isSelectable()); - std::vector> founds = {}; - - for ( auto &sel : selectors ) { - auto ret = searchableObj->findObjects(sel); - std::move(std::begin(ret), std::end(ret), std::back_inserter(founds)); - } - - if (founds.size() > 0) { - for (auto& found : founds) { - UiObject *obj = found.get(); - obj->refresh(); - if (mObjMap->getElement(obj->getId()) == nullptr) - mObjMap->addElement(std::move(found)); - - LOGI("found object : %p elementId:%s", obj, obj->getId().c_str()); - - ::aurum::Element *elm = mResponse->add_elements(); - elm->set_elementid(obj->getId()); - elm->set_package(obj->getApplicationPackage()); - - ::aurum::Rect *rect = elm->mutable_geometry(); - const Rect &size = obj->getScreenBoundingBox(); - rect->set_x(size.mTopLeft.x); - rect->set_y(size.mTopLeft.y); - rect->set_width(size.width()); - rect->set_height(size.height()); - - ::aurum::Rect *windowRect = elm->mutable_window_relative_geometry(); - const Rect &windowRelativeSize = obj->getWindowBoundingBox(); - windowRect->set_x(windowRelativeSize.mTopLeft.x); - windowRect->set_y(windowRelativeSize.mTopLeft.y); - windowRect->set_width(windowRelativeSize.width()); - windowRect->set_height(windowRelativeSize.height()); - - elm->set_widget_type(obj->getElementType()); - elm->set_widget_style(obj->getElementStyle()); - - elm->set_text(obj->getText()); - elm->set_xpath(obj->getXPath()); - elm->set_automationid(obj->getAutomationId()); - elm->set_package(obj->getApplicationPackage()); - elm->set_role(obj->getRole()); - - elm->set_ischecked(obj->isChecked()); - elm->set_ischeckable(obj->isCheckable()); - elm->set_isclickable(obj->isClickable()); - elm->set_isenabled(obj->isEnabled()); - elm->set_isfocused(obj->isFocused()); - elm->set_isfocusable(obj->isFocusable()); - elm->set_isscrollable(obj->isScrollable()); - elm->set_isselected(obj->isSelected()); - elm->set_isshowing(obj->isShowing()); - elm->set_isactive(obj->isActive()); - elm->set_isvisible(obj->isVisible()); - elm->set_isselectable(obj->isSelectable()); - } mResponse->set_status(::aurum::RspStatus::OK); + } else { + mResponse->set_status(::aurum::RspStatus::ERROR); } return grpc::Status::OK; diff --git a/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc new file mode 100644 index 0000000..74e281b --- /dev/null +++ b/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed 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 "bootstrap.h" +#include "FindElementsCommand.h" +#include "UiObject.h" +#include "UiDevice.h" +#include "UiSelector.h" +#include "Sel.h" +#include "ISearchable.h" + +FindElementsCommand::FindElementsCommand(const ::aurum::ReqFindElements *request, + ::aurum::RspFindElements *response) + : mRequest{request}, mResponse{response} +{ + mObjMap = ObjectMapper::getInstance(); +} +std::shared_ptr FindElementsCommand::getSearchableTop(void) +{ + std::shared_ptr searchableObj{nullptr}; + + if (mRequest->_elementid_case() != 0) { + searchableObj = mObjMap->getElement(mRequest->elementid()); + } + if (!searchableObj) searchableObj = UiDevice::getInstance(); + + return searchableObj; +} + +std::vector> FindElementsCommand::getSelectors(void) +{ + auto sel = std::make_shared(); + + if(mRequest->_elementid_case()) sel->id(mRequest->elementid()); + if(mRequest->_automationid_case()) sel->automationid(mRequest->automationid()); + if(mRequest->_textfield_case()) sel->text(mRequest->textfield()); + if(mRequest->_widgettype_case()) sel->type(mRequest->widgettype()); + if(mRequest->_widgetstyle_case()) sel->style(mRequest->widgetstyle()); + if(mRequest->_ischecked_case()) sel->isChecked(mRequest->ischecked()); + if(mRequest->_ischeckable_case()) sel->isCheckable(mRequest->ischeckable()); + if(mRequest->_isclickable_case()) sel->isClickable(mRequest->isclickable()); + if(mRequest->_isenabled_case()) sel->isEnabled(mRequest->isenabled()); + if(mRequest->_isfocused_case()) sel->isFocused(mRequest->isfocused()); + if(mRequest->_isfocusable_case()) sel->isFocusable(mRequest->isfocusable()); + if(mRequest->_isscrollable_case()) sel->isScrollable(mRequest->isscrollable()); + if(mRequest->_isselected_case()) sel->isSelected(mRequest->isselected()); + if(mRequest->_isshowing_case()) sel->isShowing(mRequest->isshowing()); + if(mRequest->_isactive_case()) sel->isActive(mRequest->isactive()); + if(mRequest->_mindepth_case()) sel->minDepth(mRequest->mindepth()); + if(mRequest->_maxdepth_case()) sel->maxDepth(mRequest->maxdepth()); + if(mRequest->_packagename_case()) sel->pkg(mRequest->packagename()); + if(mRequest->_textpartialmatch_case()) sel->textPartialMatch(mRequest->textpartialmatch()); + if(mRequest->_xpath_case()) sel->xpath(mRequest->xpath()); + + return std::vector>{sel}; +} + +::grpc::Status FindElementsCommand::execute() +{ + LOGI("findElements --------------- "); + auto searchableObj = getSearchableTop(); + auto selectors = getSelectors(); + + std::vector> founds = {}; + + for ( auto &sel : selectors ) { + auto ret = searchableObj->findObjects(sel); + std::move(std::begin(ret), std::end(ret), std::back_inserter(founds)); + } + + if (founds.size() > 0) { + for (auto& found : founds) { + UiObject *obj = found.get(); + obj->refresh(); + if (mObjMap->getElement(obj->getId()) == nullptr) + mObjMap->addElement(std::move(found)); + + LOGI("found object : %p elementId:%s", obj, obj->getId().c_str()); + + ::aurum::Element *elm = mResponse->add_elements(); + elm->set_elementid(obj->getId()); + elm->set_package(obj->getApplicationPackage()); + + ::aurum::Rect *rect = elm->mutable_geometry(); + const Rect &size = obj->getScreenBoundingBox(); + rect->set_x(size.mTopLeft.x); + rect->set_y(size.mTopLeft.y); + rect->set_width(size.width()); + rect->set_height(size.height()); + + ::aurum::Rect *windowRect = elm->mutable_window_relative_geometry(); + const Rect &windowRelativeSize = obj->getWindowBoundingBox(); + windowRect->set_x(windowRelativeSize.mTopLeft.x); + windowRect->set_y(windowRelativeSize.mTopLeft.y); + windowRect->set_width(windowRelativeSize.width()); + windowRect->set_height(windowRelativeSize.height()); + + elm->set_widget_type(obj->getElementType()); + elm->set_widget_style(obj->getElementStyle()); + + elm->set_text(obj->getText()); + elm->set_xpath(obj->getXPath()); + elm->set_automationid(obj->getAutomationId()); + elm->set_package(obj->getApplicationPackage()); + elm->set_role(obj->getRole()); + + elm->set_ischecked(obj->isChecked()); + elm->set_ischeckable(obj->isCheckable()); + elm->set_isclickable(obj->isClickable()); + elm->set_isenabled(obj->isEnabled()); + elm->set_isfocused(obj->isFocused()); + elm->set_isfocusable(obj->isFocusable()); + elm->set_isscrollable(obj->isScrollable()); + elm->set_isselected(obj->isSelected()); + elm->set_isshowing(obj->isShowing()); + elm->set_isactive(obj->isActive()); + elm->set_isvisible(obj->isVisible()); + elm->set_isselectable(obj->isSelectable()); + } + mResponse->set_status(::aurum::RspStatus::OK); + } else { + mResponse->set_status(::aurum::RspStatus::ERROR); + } + + return grpc::Status::OK; +} diff --git a/protocol/aurum.proto b/protocol/aurum.proto index 252a819..a9ef0f9 100644 --- a/protocol/aurum.proto +++ b/protocol/aurum.proto @@ -32,6 +32,7 @@ service Bootstrap { rpc getScreenSize(ReqGetScreenSize) returns (RspGetScreenSize) {} rpc actionAndWaitEvent(ReqActionAndWaitEvent) returns (RspActionAndWaitEvent) {} rpc setFocus(ReqSetFocus) returns (RspSetFocus) {} + rpc findElements(ReqFindElements) returns (RspFindElements) {} } // ------------------------------------ // @@ -180,7 +181,96 @@ message ReqFindElement { repeated ReqFindElement children = 21; } + message RspFindElement { + RspStatus status = 1; + Element element = 2; +} + +message ReqFindElements { + oneof _elementid { + string elementId = 1; + } + + oneof _automationid { + string automationId = 2; + } + + oneof _textfield { + string textField = 3; + } + + oneof _widgettype { + string widgetType = 4; + } + + oneof _widgetstyle { + string widgetStyle = 5; + } + + oneof _ischecked { + bool isChecked = 6; + } + + oneof _ischeckable { + bool isCheckable= 7; + } + + oneof _isclickable { + bool isClickable = 8; + } + + oneof _isenabled { + bool isEnabled = 9; + } + + oneof _isfocused { + bool isFocused = 10; + } + + oneof _isfocusable { + bool isFocusable = 11; + } + + oneof _isscrollable { + bool isScrollable = 12; + } + + oneof _isselected { + bool isSelected = 13; + } + + oneof _isshowing { + bool isShowing = 14; + } + + oneof _isactive { + bool isActive = 15; + } + oneof _mindepth { + int32 minDepth = 16; + } + + oneof _maxdepth { + int32 maxDepth = 17; + } + + oneof _packagename { + string packageName = 18; + } + + oneof _textpartialmatch { + string textPartialMatch = 19; + } + + oneof _xpath { + string xpath = 20; + } + + repeated ReqFindElements children = 21; +} + +message RspFindElements { RspStatus status = 1; repeated Element elements = 2; } diff --git a/protocol/resources/node/tv/searchAll.js b/protocol/resources/node/tv/searchAll.js index 11ed546..7d87afc 100644 --- a/protocol/resources/node/tv/searchAll.js +++ b/protocol/resources/node/tv/searchAll.js @@ -42,42 +42,40 @@ describe("Aurum Nodejs Test", function () { } }); }); - - /*it("Find SearchAll Window", function (done) { + + /*it("Find SearchAll Window", function (done) { this.timeout(15000); client.findElement({ maxDepth: 1, packageName: "com.samsung.tv.searchall", isActive: true, isShowing: true }, (err, response) => { if (err) { console.log(err); - done(err); + done(err); } else { let returnList = response.elements; assert.ok(returnList.length > 0); - console.log(returnList[0]); searchAll = returnList[0]; assert.strictEqual(searchAll.package, "com.samsung.tv.searchall"); done(); } - }); - });*/ + }); + });*/ - it("Find TextField", function (done) { + it("Find TextField", function (done) { this.timeout(15000); // assert.notEqual(searchAll, undefined); client.findElement({ widgetType: "TextField", packageName: "com.samsung.tv.searchall" }, (err, response) => { if (err) { console.log(err); - done(err); + done(err); } else { - let returnList = response.elements; - assert.ok(returnList.length > 0); - - textField = returnList[0]; + let textField = response.element; + assert.null(textField); + assert.strictEqual(textField.widget_type, "TextField"); done(); } - }); + }); }); it("Set Text", function (done) { @@ -86,12 +84,12 @@ describe("Aurum Nodejs Test", function () { client.setValue({ elementId: textField.elementId, type: 0, stringValue: "Movie" }, (err, response) => { if (err) { console.log(err); - done(err); + done(err); } else { assert.strictEqual(response.status, "OK"); done(); } - }); + }); }) }); }); diff --git a/protocol/resources/python/mobile/NUITizenGallery/NUITizenGallery.py b/protocol/resources/python/mobile/NUITizenGallery/NUITizenGallery.py index 3db24ab..b0e5528 100644 --- a/protocol/resources/python/mobile/NUITizenGallery/NUITizenGallery.py +++ b/protocol/resources/python/mobile/NUITizenGallery/NUITizenGallery.py @@ -24,23 +24,23 @@ def inScreen(size): def PickerExecuteTestWithText(stub): # 1 response = stub.findElement(ReqFindElement(widgetType='TextField')) - if len(response.elements) <= 0: return False + if response.element is None: return False # 2 - targetObj = response.elements[0].elementId + targetObj = response.element.elementId testString = 'Picker' stub.setValue(ReqSetValue(elementId=targetObj, stringValue=testString)) # 3 response = stub.findElement(ReqFindElement(textField='Run')) - if len(response.elements) <= 0: return False - targetObj = response.elements[0].elementId + if response.element is None: return False + targetObj = response.element.elementId stub.click(ReqClick(type='ELEMENTID', elementId=targetObj)) # 4 response = stub.findElement(ReqFindElement(textField='PickerTest1')) - if len(response.elements) <= 0: return False - targetObj = response.elements[0].elementId + if response.element is None: return False + targetObj = response.element.elementId stub.click(ReqClick(type='ELEMENTID', elementId=targetObj)) # 5 - response = stub.findElement(ReqFindElement(textField='Black')) + response = stub.findElements(ReqFindElements(textField='Black')) if len(response.elements) <= 0: return False return True @@ -53,8 +53,8 @@ def PickerExecuteTest(stub): # 1 stub.flick(ReqFlick(startPoint=Point(x=300, y=750), endPoint=Point(x=300, y=200), durationMs=150)) response = stub.findElement(ReqFindElement(textField='PickerTest1')) - if len(response.elements) <= 0: continue - targetObj = response.elements[0].elementId + if response.element is None: continue + targetObj = response.element.elementId response = stub.getSize(ReqGetSize(elementId=targetObj)) if inScreen(response.size): # 2 @@ -62,7 +62,7 @@ def PickerExecuteTest(stub): break # 3 - response = stub.findElement(ReqFindElement(textField='Black')) + response = stub.findElements(ReqFindElements(textField='Black')) if len(response.elements) <= 0: return False return True @@ -72,21 +72,21 @@ def PickerExecuteTest(stub): # 4. Check the loop works well while changing the picker item by flick event def PickerScrollTest(stub): # 1 - response = stub.findElement(ReqFindElement(widgetType='PickerScroller')) + response = stub.findElements(ReqFindElements(widgetType='PickerScroller')) if len(response.elements) <= 0: return False # 2 responseText = stub.findElement(ReqFindElement(textField='Black')) - if len(response.elements) <= 0: return False + if response.element is None: return False # 3 - pickerCenterX = response.elements[0].geometry.x + (response.elements[0].geometry.width / 2) - pickerCenterY = response.elements[0].geometry.y + (response.elements[0].geometry.height / 2) + pickerCenterX = response.element.geometry.x + (response.element.geometry.width / 2) + pickerCenterY = response.element.geometry.y + (response.element.geometry.height / 2) for tryCnt in range(30): # 4 stub.flick(ReqFlick(startPoint=Point(x=int(pickerCenterX), y=int(pickerCenterY)), endPoint=Point(x=int(pickerCenterX), y=int(pickerCenterY-70)), durationMs=100)) response = stub.findElement(ReqFindElement(textField='Black')) - if len(response.elements) > 0: - if response.elements[0].elementId == responseText.elements[0].elementId: + if response.element: + if response.element.elementId == responseText.element.elementId: return True return False diff --git a/protocol/resources/python/mobile/mobileDemoTest/mobileDemoTest.py b/protocol/resources/python/mobile/mobileDemoTest/mobileDemoTest.py index e7369a7..30be305 100644 --- a/protocol/resources/python/mobile/mobileDemoTest/mobileDemoTest.py +++ b/protocol/resources/python/mobile/mobileDemoTest/mobileDemoTest.py @@ -2,7 +2,6 @@ from __future__ import print_function import os import sys sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))) -from __future__ import print_function from aurum_pb2 import * from aurum_pb2_grpc import BootstrapStub import logging @@ -11,12 +10,11 @@ import time def findElementTest(stub): response = stub.findElement(ReqFindElement(isClickable=True)) - for el in response.elements: - return True + if response.element: return True return False def getValueTest(stub): - response = stub.findElement(ReqFindElement(textField='Button')) + response = stub.findElements(ReqFindElements(textField='Button')) print("els", response) for el in response.elements: response = stub.getValue(ReqGetValue(elementId=el.elementId)) @@ -34,8 +32,8 @@ def setValueClearTest(stub): for tryCnt in range(10): stub.flick(ReqFlick(startPoint=Point(x=160, y=350), endPoint=Point(x=160, y=10), durationMs=500)) response = stub.findElement(ReqFindElement(textField='Entry')) - if len(response.elements) <= 0: continue - targetObj = response.elements[0].elementId + if response.element is None: continue + targetObj = response.element.elementId response = stub.getSize(ReqGetSize(elementId=targetObj)) if inScreen(response.size): stub.click(ReqClick(type='ELEMENTID', elementId=targetObj)) @@ -44,8 +42,8 @@ def setValueClearTest(stub): for tryCnt in range(10): stub.flick(ReqFlick(startPoint=Point(x=160, y=350), endPoint=Point(x=160, y=10), durationMs=500)) response = stub.findElement(ReqFindElement(textField='Singleline Entry')) - if len(response.elements) <= 0: continue - targetObj = response.elements[0].elementId + if response.element is None: continue + targetObj = response.element.elementId response = stub.getSize(ReqGetSize(elementId=targetObj)) isShowing = stub.getAttribute(ReqGetAttribute(elementId=targetObj, attribute='SHOWING')).boolValue if inScreen(response.size) or isShowing: @@ -53,8 +51,8 @@ def setValueClearTest(stub): break response = stub.findElement(ReqFindElement(widgetType='Elm_Entry')) - if len(response.elements) <= 0: return False - targetObj = response.elements[0].elementId + if response.element is None: return False + targetObj = response.element.elementId testString = 'set test string by calling SetValue Method' stub.setValue(ReqSetValue(elementId=targetObj, stringValue=testString)) @@ -71,7 +69,7 @@ def setValueClearTest(stub): return True def getSizeTest(stub): - response = stub.findElement(ReqFindElement(textField='Button')) + response = stub.findElements(ReqFindElements(textField='Button')) print("els", response) for el in response.elements: response = stub.getSize(ReqGetSize(elementId=el.elementId)) @@ -80,7 +78,7 @@ def getSizeTest(stub): return False def getAttributeTest(stub): - response = stub.findElement(ReqFindElement(textField='Button')) + response = stub.findElements(ReqFindElements(textField='Button')) if len(response.elements) <= 0: return False checkList = [ @@ -104,7 +102,7 @@ def getAttributeTest(stub): if isFailed == True: return False - response = stub.findElement(ReqFindElement(textField='Check')) + response = stub.findElements(ReqFindElements(textField='Check')) if len(response.elements) <= 0: return False checkList = [ @@ -129,19 +127,19 @@ def getAttributeTest(stub): return isFailed == False def clickTest(stub): - response = stub.findElement(ReqFindElement(textField='Accessibility')) + response = stub.findElements(ReqFindElements(textField='Accessibility')) if len(response.elements) <= 0: return False for el in response.elements: stub.click(ReqClick(elementId=el.elementId, type='ELEMENTID')) - response = stub.findElement(ReqFindElement(textField='Screen Reader')) + response = stub.findElements(ReqFindElements(textField='Screen Reader')) if len(response.elements) <= 0: return False for el in response.elements: stub.click(ReqClick(coordination=Point(x=320, y=130), type='COORD')) - response = stub.findElement(ReqFindElement(textField='UI Descriptions')) + response = stub.findElements(ReqFindElements(textField='UI Descriptions')) if len(response.elements) <= 0: return False return True @@ -154,13 +152,13 @@ def longClickTest(stub): def flickTest(stub): response = stub.findElement(ReqFindElement(textField='Bg', isShowing=True)) - if len(response.elements) <= 0: return False - targetObj = response.elements[0].elementId + if response.element is None: return False + targetObj = response.element.elementId for tryCnt in range(10): print('Flick to bottom to find "Spinner" item @ tries:', tryCnt) stub.flick(ReqFlick(startPoint=Point(x=160, y=359), endPoint=Point(x=160, y=1), durationMs=110)) - response = stub.findElement(ReqFindElement(textField='Spinner')) + response = stub.findElements(ReqFindElements(textField='Spinner')) time.sleep(0.01) print(response) if len(response.elements) > 0: diff --git a/protocol/resources/python/tv/NUITizenGalleryTV/NUITizenGalleryTV.py b/protocol/resources/python/tv/NUITizenGalleryTV/NUITizenGalleryTV.py index 304ffa8..d908383 100644 --- a/protocol/resources/python/tv/NUITizenGalleryTV/NUITizenGalleryTV.py +++ b/protocol/resources/python/tv/NUITizenGalleryTV/NUITizenGalleryTV.py @@ -24,23 +24,23 @@ def inScreen(size): def PickerExecuteTestWithText(stub): # 1 response = stub.findElement(ReqFindElement(widgetType='TextField')) - if len(response.elements) <= 0: return False + if response.element is None: return False # 2 - targetObj = response.elements[0].elementId + targetObj = response.element.elementId testString = 'Picker' stub.setValue(ReqSetValue(elementId=targetObj, stringValue=testString)) # 3 response = stub.findElement(ReqFindElement(textField='Run')) - if len(response.elements) <= 0: return False - targetObj = response.elements[0].elementId + if response.element is None: return False + targetObj = response.element.elementId stub.click(ReqClick(type='ELEMENTID', elementId=targetObj)) # 4 response = stub.findElement(ReqFindElement(textField='PickerTest1')) - if len(response.elements) <= 0: return False - targetObj = response.elements[0].elementId + if response.element is None: return False + targetObj = response.element.elementId stub.click(ReqClick(type='ELEMENTID', elementId=targetObj)) # 5 - response = stub.findElement(ReqFindElement(textField='Black')) + response = stub.findElements(ReqFindElements(textField='Black')) if len(response.elements) <= 0: return False return True @@ -53,8 +53,8 @@ def PickerExecuteTest(stub): # 1 stub.flick(ReqFlick(startPoint=Point(x=300, y=750), endPoint=Point(x=300, y=200), durationMs=150)) response = stub.findElement(ReqFindElement(textField='PickerTest1')) - if len(response.elements) <= 0: continue - targetObj = response.elements[0].elementId + if response.elements is None: continue + targetObj = response.element.elementId response = stub.getSize(ReqGetSize(elementId=targetObj)) if inScreen(response.size): # 2 @@ -62,7 +62,7 @@ def PickerExecuteTest(stub): break # 3 - response = stub.findElement(ReqFindElement(textField='Black')) + response = stub.findElements(ReqFindElements(textField='Black')) if len(response.elements) <= 0: return False return True @@ -72,14 +72,14 @@ def PickerExecuteTest(stub): # 4. Check the loop works well while changing the picker item by flick event def PickerScrollTest(stub): # 1 - response = stub.findElement(ReqFindElement(widgetType='PickerScroller')) + response = stub.findElements(ReqFindElements(widgetType='PickerScroller')) if len(response.elements) <= 0: return False # 2 responseText = stub.findElement(ReqFindElement(textField='Black')) - if len(response.elements) <= 0: return False + if response.element is None: return False # 3 - pickerCenterX = response.elements[0].geometry.x + (response.elements[0].geometry.width / 2) - pickerCenterY = response.elements[0].geometry.y + (response.elements[0].geometry.height / 2) + pickerCenterX = response.element.geometry.x + (response.element.geometry.width / 2) + pickerCenterY = response.element.geometry.y + (response.element.geometry.height / 2) for tryCnt in range(30): # 4 @@ -87,8 +87,8 @@ def PickerScrollTest(stub): # Wait until view update time.sleep(0.3) response = stub.findElement(ReqFindElement(textField='Black')) - if len(response.elements) > 0: - if response.elements[0].elementId == responseText.elements[0].elementId: + if response.element: + if response.element.elementId == responseText.element.elementId: return True return False diff --git a/protocol/resources/python/tv/multiView.py b/protocol/resources/python/tv/multiView.py index a6f2a9a..b404739 100644 --- a/protocol/resources/python/tv/multiView.py +++ b/protocol/resources/python/tv/multiView.py @@ -12,10 +12,10 @@ import time # Please refer key codes below page # https://code.sec.samsung.net/confluence/display/GFX/VD+Key+Code+Table def MultiViewSizeTest(stub): - response = stub.findElement(ReqFindElement(textField='VSComponent2')) + response = stub.findElements(ReqFindElements(textField='VSComponent2')) if len(response.elements) <= 0: return False - responseGuide = stub.findElement(ReqFindElement(textField='Guide TextBox')) + responseGuide = stub.findElements(ReqFindElements(textField='Guide TextBox')) if len(response.elements) <= 0: stub.sendKey(ReqKey(type='XF86', actionType='STROKE', XF86keyCode='Return')) @@ -26,9 +26,9 @@ def MultiViewSizeTest(stub): time.sleep(1) responseAfter = stub.findElement(ReqFindElement(textField='VSComponent2')) - if len(responseAfter.elements) <= 0: return False + if responseAfter.element is None: return False - if response.elements[0].geometry.width < responseAfter.elements[0].geometry.width: + if response.element.geometry.width < responseAfter.element.geometry.width: return True return False @@ -43,7 +43,7 @@ def MultiViewContentsTest(stub): time.sleep(10) # It fails if there is a View - response= stub.findElement(ReqFindElement(textField='VSComponent2')) + response= stub.findElements(ReqFindElements(textField='VSComponent2')) if len(response.elements) > 0: return False stub.sendKey(ReqKey(type='XF86', actionType='LONG_STROKE', XF86keyCode='XF86Back')) diff --git a/protocol/resources/python/tv/searchAll.py b/protocol/resources/python/tv/searchAll.py index 4b9ccc3..a03d2b2 100644 --- a/protocol/resources/python/tv/searchAll.py +++ b/protocol/resources/python/tv/searchAll.py @@ -11,8 +11,8 @@ import time # Find TextField and input "Movie" text def SearchTestWithText(stub): response = stub.findElement(ReqFindElement(widgetType='TextField')) - if len(response.elements) <= 0: return False - targetObj = response.elements[0].elementId + if response.element is None: return False + targetObj = response.element.elementId testString = 'Movie' stub.setValue(ReqSetValue(elementId=targetObj, stringValue=testString)) @@ -24,16 +24,16 @@ def SearchTestWithText(stub): # Find Foused item and move focus to right then compare focused item with previous one def SearchFocusedObject(stub): response = stub.findElement(ReqFindElement(isFocused=True)) - if len(response.elements) <= 0: return False + if response.elements is None: return False - prevObj = response.elements[0].elementId + prevObj = response.element.elementId stub.sendKey(ReqKey(type='XF86', actionType='LONG_STROKE', XF86keyCode='Right')) time.sleep(1) response = stub.findElement(ReqFindElement(isFocused=True)) - if len(response.elements) <= 0: return False + if response.elements is None: return False - if prevObj != response.elements[0].elementId: + if prevObj != response.element.elementId: return True return False