51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

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

怎么在alert 上进行操作

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2012-5-14 18:06:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 dian106106 于 2012-5-14 18:07 编辑



点击 www.msn.com  右上角上的link“ Make xinmsn my homepage ” , 弹出了个alert  如上图, 怎么在上面进行操作,选yes 和no。。。。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
 楼主| 发表于 2012-5-14 18:11:53 | 只看该作者
对了, 只能在ie上可以看到这个link,其他浏览器上没有的
附上一点脚本,请大家继续。。。。。
WebDriver driver = new InternetExplorerDriver();
             String baseurl = "http://xin.msn.com/?lang=en-sg";
              driver.get(baseurl);
              try {
                        Thread.sleep(3000);
                } catch (InterruptedException e) {
                        e.printStackTrace();
                }
             driver.findElement(By.linkText("Make xinmsn my homepage")).click();
            Alert alert = driver.switchTo().alert();
                if(!alert.getText().equalsIgnoreCase("Would you like to use the following as your home page?")){
                        System.out.println("DHP alert not popup, pls check...");
                }
//请继续。。。。。。
回复 支持 反对

使用道具 举报

该用户从未签到

3#
 楼主| 发表于 2012-5-14 18:12:14 | 只看该作者
对了, 只能在ie上可以看到这个link,其他浏览器上没有的
附上一点脚本,请大家继续。。。。。
WebDriver driver = new InternetExplorerDriver();
             String baseurl = "http://xin.msn.com/?lang=en-sg";
              driver.get(baseurl);
              try {
                        Thread.sleep(3000);
                } catch (InterruptedException e) {
                        e.printStackTrace();
                }
             driver.findElement(By.linkText("Make xinmsn my homepage")).click();
            Alert alert = driver.switchTo().alert();
                if(!alert.getText().equalsIgnoreCase("Would you like to use the following as your home page?")){
                        System.out.println("DHP alert not popup, pls check...");
                }
//请继续。。。。。。
回复 支持 反对

使用道具 举报

本版积分规则

关闭

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

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

GMT+8, 2024-5-5 21:55 , Processed in 0.069601 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

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