51Testing软件测试论坛

标题: 怎么在alert 上进行操作 [打印本页]

作者: dian106106    时间: 2012-5-14 18:06
标题: 怎么在alert 上进行操作
本帖最后由 dian106106 于 2012-5-14 18:07 编辑

[attach]78986[/attach]

点击 www.msn.com  右上角上的link“ Make xinmsn my homepage ” , 弹出了个alert  如上图, 怎么在上面进行操作,选yes 和no。。。。
作者: dian106106    时间: 2012-5-14 18:11
对了, 只能在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...");
                }
//请继续。。。。。。
作者: dian106106    时间: 2012-5-14 18:12
对了, 只能在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...");
                }
//请继续。。。。。。




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2