aurum: add XPath interface to search object in object tree 55/273255/2
authorHosang Kim <hosang12.kim@samsung.com>
Fri, 1 Apr 2022 08:22:03 +0000 (17:22 +0900)
committerHosang Kim <hosang12.kim@samsung.com>
Mon, 4 Apr 2022 06:54:13 +0000 (15:54 +0900)
Change-Id: I92e6fd2d0e62ff65634e5e81ee7ae57557017d68

libaurum/inc/UiSelector.h
libaurum/src/UiSelector.cc
org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc
protocol/aurum.proto

index f834b17407a8f3c4acb98e6226858e8ecc68973a..c8f510db49d825371ef28762a4aa1512137bae8d 100644 (file)
@@ -346,6 +346,17 @@ public:
      */
     UiSelector *fromParent(std::shared_ptr<UiSelector> parent);
 
+    /**
+     * @brief Sets the search criteria to match the object's XPath.
+     *
+     * @param[in] xpath object XPath
+     *
+     * @return UiSelector class instance
+     *
+     * @since_tizen 7.0
+     */
+    UiSelector *xpath(std::string xpath);
+
 public:
     std::string mId;
     std::string mAutomationId;
@@ -355,6 +366,7 @@ public:
     std::string mType;
     std::string mStyle;
     std::string mTextPartialMatch;
+    std::string mXPath;
 
     bool mMatchId;
     bool mMatchAutomationId;
@@ -364,6 +376,7 @@ public:
     bool mMatchType;
     bool mMatchStyle;
     bool mMatchTextPartialMatch;
+    bool mMatchXPath;
 
     bool mMatchChecked;
     bool mMatchCheckable;
index fe2ba4a44886352896699a28c519ae0bf99df147..f97aea39a10acb91318adfe80818667772fe3a26 100644 (file)
@@ -23,8 +23,8 @@ using namespace Aurum;
 
 UiSelector::UiSelector()
 : mId{}, mAutomationId{}, mRole{}, mText{}, mTextPartialMatch{}, mPkg{}, mType{}, mStyle{},
-  mMatchId{}, mMatchAutomationId{}, mMatchRole{}, mMatchText{}, mMatchTextPartialMatch{}, mMatchPkg{}, mMatchType{},
-  mMatchStyle{}, mMatchChecked{}, mMatchCheckable{}, mMatchClickable{}, mMatchEnabled{}, mMatchFocused{},
+  mMatchId{}, mMatchAutomationId{}, mMatchRole{}, mMatchText{}, mMatchTextPartialMatch{}, mMatchXPath{}, mMatchPkg{},
+  mMatchType{}, mMatchStyle{}, mMatchChecked{}, mMatchCheckable{}, mMatchClickable{}, mMatchEnabled{}, mMatchFocused{},
   mMatchFocusable{}, mMatchScrollable{}, mMatchSelected{}, mMatchShowing{}, mMatchActive{}, mMatchVisible{},
   mMatchSelectable{}, mMinDepth{}, mMaxDepth{}, mIschecked{}, mIscheckable{}, mIsclickable{}, mIsenabled{},
   mIsfocused{}, mIsfocusable{}, mIsscrollable{}, mIsselected{}, mIsshowing{}, mIsactive{}, mIsvisible{},
@@ -41,6 +41,7 @@ std::string UiSelector::description()
     if(!this->mRole.empty()) ss << "\"mRole\":\"" << this->mRole << "\", ";
     if(!this->mText.empty()) ss << "\"mText\":\"" << this->mText << "\", ";
     if(!this->mTextPartialMatch.empty()) ss << "\"mTextPartialMatch\":\"" << this->mTextPartialMatch << "\", ";
+    if(!this->mXPath.empty()) ss << "\"mXPath\":\"" << this->mXPath << "\", ";
     if(!this->mPkg.empty()) ss << "\"mPkg\":\"" << this->mPkg << "\", ";
     if(!this->mType.empty()) ss << "\"mType\":\"" << this->mType << "\", ";
     if(!this->mStyle.empty()) ss << "\"mStyle\":\"" << this->mStyle << "\", ";
@@ -49,6 +50,7 @@ std::string UiSelector::description()
     if(this->mMatchRole) ss << "\"mMatchRole\":\"" << ((this->mMatchRole)?"true":"false") << "\", ";
     if(this->mMatchText) ss << "\"mMatchText\":\"" << ((this->mMatchText)?"true":"false") << "\", ";
     if(this->mMatchTextPartialMatch) ss << "\"mMatchTextPartialMatch\":\"" << ((this->mMatchTextPartialMatch)?"true":"false") << "\", ";
+    if(this->mMatchXPath) ss << "\"mMatchXPath\":\"" << ((this->mMatchXPath)?"true":"false") << "\", ";
     if(this->mMatchPkg) ss << "\"mMatchPkg\":\"" << ((this->mMatchPkg)?"true":"false") << "\", ";
     if(this->mMatchType) ss << "\"mMatchType\":\"" << ((this->mMatchType)?"true":"false") << "\", ";
     if(this->mMatchStyle) ss << "\"mMatchStyle\":\"" << ((this->mMatchStyle)?"true":"false" )<< "\", ";
@@ -115,6 +117,13 @@ UiSelector *UiSelector::automationid(std::string text)
     return this;
 }
 
+UiSelector *UiSelector::xpath(std::string xpath)
+{
+    this->mXPath = xpath;
+    this->mMatchXPath = true;
+    return this;
+}
+
 UiSelector *UiSelector::role(std::string text)
 {
     this->mRole = text;
index 1ad25dc07179a17ddbddf771886263b4c68fa512..5e25eceebf66f977cdb79b41b30dffe461ebf598 100644 (file)
@@ -64,6 +64,7 @@ std::vector<std::shared_ptr<UiSelector>> FindElementCommand::getSelectors(void)
     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<std::shared_ptr<UiSelector>>{sel};
 }
@@ -112,6 +113,7 @@ std::vector<std::shared_ptr<UiSelector>> FindElementCommand::getSelectors(void)
             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());
index a6edb5985619531cb551bafefaa42ef725d3ebaa..bca9eb404ffa8c612e7a40834a9b0ab9370e9e1f 100644 (file)
@@ -174,7 +174,11 @@ message ReqFindElement {
       string textPartialMatch = 19;
    }
 
-   repeated ReqFindElement children = 20;
+   oneof _xpath {
+      string xpath = 20;
+   }
+
+   repeated ReqFindElement children = 21;
 }
 message RspFindElement {
    RspStatus status = 1;