网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Se(11)---Alert

package testWd;

专注于为中小企业提供成都做网站、成都网站设计服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业海南免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上1000+企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

import org.openqa.selenium.Alert;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

import org.testng.annotations.Test;

public class findEle {

@Test

public void findElement() throws InterruptedException {

System.setProperty("webdriver.chrome.driver", "D:/01 Learn WebDriver/chromedriver.exe");

WebDriver dr = new ChromeDriver();

dr.manage().window().maximize();

//Alert

/*dr.get("http://www.w3school.com.cn/tiy/t.asp?f=hdom_alert");

WebElement el = dr.findElement(By.xpath("//*[@name='i']"));

dr.switchTo().frame("i");

WebElement el1 = dr.findElement(By.xpath("//input"));

el1.click();

Alert alert1 = dr.switchTo().alert();

System.out.println(alert1.getText());

Thread.sleep(5000);

alert1.accept();*/

//confirm

/*dr.get("http://www.w3school.com.cn/tiy/t.asp?f=hdom_confirm");

WebElement el = dr.findElement(By.xpath("//*[@name='i']"));

dr.switchTo().frame("i");

WebElement el1 = dr.findElement(By.xpath("//input"));

el1.click();

   Alert confirm1 = dr.switchTo().alert();

   Thread.sleep(2000);

System.out.println(confirm1.getText());

confirm1.accept();

Thread.sleep(2000);

confirm1 = dr.switchTo().alert();

Thread.sleep(2000);

System.out.println(confirm1.getText());

confirm1.accept();

el1.click();

confirm1 = dr.switchTo().alert();

Thread.sleep(2000);

System.out.println(confirm1.getText());

confirm1.dismiss();

Thread.sleep(2000);

confirm1 = dr.switchTo().alert();

System.out.println(confirm1.getText());

confirm1.accept();*/

//Prompt

dr.get("http://www.w3school.com.cn/tiy/t.asp?f=hdom_prompt");

WebElement el = dr.findElement(By.xpath("//*[@name='i']"));

dr.switchTo().frame(el);

WebElement el1 = dr.findElement(By.xpath("//input"));

el1.click();

   Alert prompt1 = dr.switchTo().alert();

   Thread.sleep(2000);

System.out.println(prompt1.getText());

prompt1.dismiss();

WebElement el2 = dr.findElement(By.xpath("/html/body"));

System.out.println(el2.getText());

Thread.sleep(2000);

el1.click();

   prompt1 = dr.switchTo().alert();

   Thread.sleep(2000);

System.out.println(prompt1.getText());

prompt1.sendKeys("Jerry");

prompt1.accept();

el2 = dr.findElement(By.xpath("/html/body"));

System.out.println(el2.getText());

//Thread.sleep(3000);

//dr.quit();

}

}


分享名称:Se(11)---Alert
本文网址:http://bjjierui.cn/article/jgogge.html

其他资讯