【问题标题】:Facing exception: org.openqa.selenium.NoSuchSessionException: A session is either terminated or not started site:stackoverflow.com面临异常:org.openqa.selenium.NoSuchSessionException:会话已终止或未启动站点:stackoverflow.com
【发布时间】:2020-02-11 14:28:16
【问题描述】:

我正在使用 selenium + TestNG + Appium 在我的 MAC OS(eclipse IDE)中的模拟器设备上使用移动关键字框架模型执行自动化,

通过 .pom 文件使用以下版本:

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

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.14.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>3.14.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-remote-driver</artifactId>
        <version>3.14.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>3.14.0</version>
    </dependency>


    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>3.14.0</version>
    </dependency>

大部分动作功能都很好,但我有一个关键字,每次在不同的 TestData(电子商务移动应用上的产品 ID)上重复执行 9 次动作大约需要 115 秒

关键字执行以下操作: 1.清除搜索产品文本字段。 2.在搜索框输入productID。 3. 从列表中选择找到的产品。 4.当产品详细信息页面出现时,复制(到ArrayList)产品详细信息并打印到日志+报告。 5. 点击+将该产品加入购物车

这意味着对一个关键字进行 5 次操作 所以我想每次操作都需要太多时间 问题是

对于 6-7 个产品,它运行良好,但下一个产品会导致此异常:

    org.openqa.selenium.NoSuchSessionException: A session is either terminated or not started site:stackoverflow.com

问题是当我长时间没有操作 MAC PC 时,我在哪里更改了等待时间 - 还将 MAC 系统偏好设置节能器更改为插入电源线时从不休眠 为了使模拟器不会长时间终止TestCase?

提前感谢任何为我解决此问题的人 :-)

【问题讨论】:

    标签: java selenium appium appium-android


    【解决方案1】:

    MAC System Preferences energy saver to Never sleep when plug to the power cable以便模拟器不会长时间终止TestCase这与JavaAppium无关。 由于驱动程序超时,您会收到此异常,您可以通过调用设置自己的超时: driver.manage().timeouts().implicitlyWait(200, TimeUnit.SECONDS);

    【讨论】:

    • 在模拟器上测试时,我已经这样做了并且 cat 甚至将 30 秒的时间统一起来没有任何问题,可能只是模拟器的问题。使用真实设备不会发生这种情况
    猜你喜欢
    • 1970-01-01
    • 2021-08-05
    • 1970-01-01
    • 2019-09-23
    • 2021-10-10
    • 2017-10-30
    • 2019-07-27
    • 2011-01-25
    • 1970-01-01
    相关资源
    最近更新 更多