51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 2165|回复: 2
打印 上一主题 下一主题

再次求教IDE的菜鸟级问题

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2015-6-29 15:20:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
业务逻辑是点击保存按钮保存信息后,弹出alert “保存成功”,然后点击生成按钮,弹出alert “生成成功”
现在加上assertAlert 保存成功,用例执行失败,日志为 [error] There were no alerts
去掉assertAlert 保存成功,用例执行还是失败,日志为 [error] There was an unexpected Alert! [保存成功]
求大神指导
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

  • TA的每日心情
    慵懒
    15 小时前
  • 签到天数: 2678 天

    连续签到: 4 天

    [LV.Master]测试大本营

    2#
    发表于 2015-6-30 12:22:38 | 只看该作者
    可能由于一个页面加载延迟造成的,在命令执行时,其中被定位器标识的元素还没有被完全加载。
    建议在命令前加入延迟,来判断页面是否因为加载延迟造成的问题.

    评分

    参与人数 1测试积点 +10 收起 理由
    lsekfe + 10 恭喜你获得测试积点10

    查看全部评分

    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    无聊
    2020-12-8 11:20
  • 签到天数: 605 天

    连续签到: 1 天

    [LV.9]测试副司令

    3#
    发表于 2015-7-6 13:38:23 | 只看该作者
    alert是需要切换的。。。

    /**
             * Handling a simple JavaScript alert
             */
            public static void AlertHandling(boolean acceptNextAlert, String alertText) {
                    try {
                            // Get the Alert
                            Alert alert = driver.switchTo().alert();
                            // Get the Text displayed on Alert using getText() method of Alert
                            // class
                            String textOnAlert = alert.getText();

                            if (acceptNextAlert) {
                                    // Click OK button, by calling accept() method of Alert Class
                                    alert.accept();
                            } else {
                                    // Click cancel button, by calling dismiss() method of Alert
                                    // Class
                                    alert.dismiss();
                            }
                            // Verify Alert displayed correct message to user
                            Assert.assertTrue(textOnAlert.contains(alertText));
                    } catch (NoAlertPresentException e) {
                            e.printStackTrace();
                    }
            }
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-5-23 22:41 , Processed in 0.065821 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表