Used for get the bounding boxes of the specified actions \param action The action specified by users, need to query its bounding box from XML tree \param rootXML The XML tree of the current page \return If the bonding box of the action is found, return true.
| 167 | /// \param rootXML The XML tree of the current page |
| 168 | /// \return If the bonding box of the action is found, return true. |
| 169 | bool Preference::patchActionBounds(const CustomActionPtr &action, const ElementPtr &rootXML) { |
| 170 | if (nullptr == action) |
| 171 | return false; |
| 172 | std::vector<ElementPtr> elementVector; // vector for storing elements satisfying xpath selector |
| 173 | this->findMatchedElements(elementVector, action->xpath, rootXML); |
| 174 | if (!elementVector.empty()) { |
| 175 | // the matched elements could be more than one, but we only use the first matched one |
| 176 | RectPtr rect = elementVector.at(0)->getBounds(); |
| 177 | action->bounds.push_back(static_cast<float>(rect->left)); |
| 178 | action->bounds.push_back(static_cast<float>(rect->top)); |
| 179 | action->bounds.push_back(static_cast<float>(rect->right)); |
| 180 | action->bounds.push_back(static_cast<float>(rect->bottom)); |
| 181 | } else { |
| 182 | // action->bounds.clear(); |
| 183 | BLOG("action xpath not found %s", action->xpath->toString().c_str()); |
| 184 | return false; |
| 185 | } |
| 186 | return true; |
| 187 | } |
| 188 | |
| 189 | void Preference::patchOperate(const OperatePtr &opt) { |
| 190 | if (!this->_doInputFuzzing) |
no test coverage detected