为什么我在 Appium+ Flutter Automation 代码中遇到 No such element found 错误?

问题描述 投票:0回答:1

我是使用 appium 进行颤动自动化的新手。我遵循了互联网上的例子。但它给了我没有找到这样的元素错误。基本上我试图用 ValueKey、Sementiclabel 来识别元素。这是我试图执行自动化的代码。

public static void main(String[] args) throws MalformedURLException, InterruptedException {

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("deviceName", "Android");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("noReset", true);
    capabilities.setCapability("automationName", "Appium");
    capabilities.setCapability("app", "E:\\app-debug.apk");
    URL url = new URL("http://localhost:4723/wd/hub");
    AndroidDriver<WebElement> driver = new AndroidDriver<WebElement>(url, capabilities);

    FlutterFinder find = new FlutterFinder(driver);
    FlutterElement e = find.bySemanticsLabel("text");
    e.getText();
    System.out.println(value);

这些是我的 pom.xml 文件中使用的依赖项。

<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
        <version>4.1.2</version>
</dependency>

<dependency>
    <groupId>io.github.ashwithpoojary98</groupId>
    <artifactId>appium_flutterfinder_java</artifactId>
        <version>1.0.0</version>
</dependency>

我在应用程序的源代码中添加了开发依赖项,如下所示 pubspec.yaml

dev_dependencies:
    test: any
    flutter_test:
        sdk: flutter
    flutter_driver:
        sdk: flutter

main.dart文件中的代码也这样改。

import 'package:flutter_driver/driver_extension.dart';
void main() {
    enableFlutterDriverExtension();
    runApp(const MyApp());

这是我收到的错误消息

Exception in thread "main" org.openqa.selenium.NoSuchElementException: The element identified by 'eyJpc1JlZ0V4cCI6ImZhbHNlIiwibGFiZWwiOiJ0ZXh0IiwiZmluZGVyVHlwZSI6IkJ5U2VtYW50aWNzTGFiZWwifQ==' is not present in the cache or has expired. Try to find it again (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 191 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'Isuru', ip: '192.168.137.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '19.0.1'
Driver info: io.appium.java_client.android.AndroidDriver
flutter automation appium nosuchelementexception
1个回答
0
投票

我们的自动化名称无效

  capabilities.setCapability("automationName", "Appium");

使用以下内容代替:

  1. Uiautomator2
  2. 颤动
© www.soinside.com 2019 - 2024. All rights reserved.