com.kingsware.uiautomator.automator.Selector@15efac; boundsInParent: Rect(0, 0 - 729, 68); boundsInScreen: Rect(228, 471 - 957, 539); packageName: com.tencent.mm; className: android.view.View; text: 微信发送测试群; contentDescription: null; viewId: com.tencent.mm:id/hg4; checkable: false; checked: false; focusable: false; focused: false; selected: false; clickable: false; longClickable: false; enabled: true; password: false; scrollable: false; [ACTION_SELECT, ACTION_CLEAR_SELECTION, ACTION_ACCESSIBILITY_FOCUS, ACTION_SHOW_ON_SCREEN],请写一个js的正则表达式把boundsInScreen:Rect()里面的数据提取出来
时间: 2024-03-12 08:46:19 浏览: 4
以下是提取boundsInScreen:Rect()里面的数据的js正则表达式:
```
/boundsInScreen: Rect\((\d+), (\d+) - (\d+), (\d+)\)/
```
该正则表达式可以匹配包含boundsInScreen:Rect()信息的字符串,并将四个数字分别提取出来。其中,第一个数字表示左上角的x坐标,第二个数字表示左上角的y坐标,第三个数字表示右下角的x坐标,第四个数字表示右下角的y坐标。
相关问题
com.kingsware.uiautomator.automator.Selector@15efac; boundsInParent: Rect(0, 0 - 729, 68); boundsInScreen: Rect(228, 471 - 957, 539); packageName: com.tencent.mm; className: android.view.View; text: 微信发送测试群; contentDescription: null; viewId: com.tencent.mm:id/hg4; checkable: false; checked: false; focusable: false; focused: false; selected: false; clickable: false; longClickable: false; enabled: true; password: false; scrollable: false; [ACTION_SELECT, ACTION_CLEAR_SELECTION, ACTION_ACCESSIBILITY_FOCUS, ACTION_SHOW_ON_SCREEN],请写一个js通过正则表达式把boundsInScreen:Rect()里面的数据提取出来
好的,可以使用正则表达式来提取这个字符串中的boundsInScreen数据,下面是一个示例的JavaScript代码:
```javascript
// 要提取的字符串
const str = 'com.kingsware.uiautomator.automator.Selector@15efac; boundsInParent: Rect(0, 0 - 729, 68); boundsInScreen: Rect(228, 471 - 957, 539); packageName: com.tencent.mm; className: android.view.View; text: 微信发送测试群; contentDescription: null; viewId: com.tencent.mm:id/hg4; checkable: false; checked: false; focusable: false; focused: false; selected: false; clickable: false; longClickable: false; enabled: true; password: false; scrollable: false; [ACTION_SELECT, ACTION_CLEAR_SELECTION, ACTION_ACCESSIBILITY_FOCUS, ACTION_SHOW_ON_SCREEN]';
// 使用正则表达式匹配boundsInScreen数据
const regex = /boundsInScreen: Rect\((\d+), (\d+) - (\d+), (\d+)\)/;
const match = str.match(regex);
// 输出匹配结果
if (match) {
const [, left, top, right, bottom] = match;
console.log(`boundsInScreen: left=${left}, top=${top}, right=${right}, bottom=${bottom}`);
} else {
console.log('没有匹配到boundsInScreen数据');
}
```
输出结果:
```
boundsInScreen: left=228, top=471, right=957, bottom=539
```
这样就成功提取出了boundsInScreen中的左、上、右、下四个坐标值。
com.android.support.test.uiautomator:uiautomator-v18:2.1.3的API的UiDevice无法使用
可能是因为你的项目使用的是 AndroidX 库,而不是旧的 Support 库。AndroidX 库中没有 `com.android.support.test.uiautomator` 包,因此无法使用 `UiDevice` 类。你可以尝试使用 AndroidX 提供的替代方案,如 Espresso 或 UI Automator 2.0。如果你确实需要使用旧的 Support 库,可以尝试使用 `android.support.test.uiautomator.UiDevice` 类。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)