十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
package testWd;
專注于為中小企業(yè)提供成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)海南免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上1000+企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
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("http://*[@name='i']"));
dr.switchTo().frame("i");
WebElement el1 = dr.findElement(By.xpath("http://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("http://*[@name='i']"));
dr.switchTo().frame("i");
WebElement el1 = dr.findElement(By.xpath("http://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("http://*[@name='i']"));
dr.switchTo().frame(el);
WebElement el1 = dr.findElement(By.xpath("http://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();
}
}