selenium实战:操作3种提示框

package javaBase;

import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.Set;


/**
 * java selenium 操作弹出对话框
 * Web 开发人员通常需要利用JavaScript弹出对话框来给用户一些信息提示, 包括以下几种类型
 */
public class TestSetSeleniumServerJAR {
    public static void main(String[] args) {

        //谷歌浏览器
        WebDriver driver = new ChromeDriver();

        /**
         * 测试警告框: 用于提示用户相关信息的验证结果, 错误或警告等
         */
/*        String url="http://localhost:8888/selenium/";
        driver.get(url);

        WebElement alertButton = driver.findElement(By.xpath("//input[@value='alert']"));
        alertButton.click();

        Alert javascriptAlert = driver.switchTo().alert();
        System.out.println(javascriptAlert.getText());
        javascriptAlert.accept();*/


        /**
         * 测试提示框: 用于提示用户在当前对话框中输入数据,一般需要用户单击取消或者确认按钮
         */

/*        String url="http://localhost:8888/selenium/";
        driver.get(url);

        WebElement promptButton = driver.findElement(By.xpath("//input[@value='prompt']"));
        promptButton.click();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Alert javascriptPrompt = driver.switchTo().alert();
        javascriptPrompt.sendKeys("This is learning Selenium");
        javascriptPrompt.accept();

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

        javascriptPrompt=driver.switchTo().alert();
        javascriptPrompt.accept();

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        promptButton.click();
        javascriptPrompt=driver.switchTo().alert();
        javascriptPrompt.dismiss();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        javascriptPrompt=driver.switchTo().alert();
        javascriptPrompt.accept();*/


        /**
         * 测试确认框: 用于提示用户确认或者取消某个操作,一般需要用户单击取消或者确认按钮
         */

        String url="http://localhost:8888/selenium/";
        driver.get(url);

        WebElement confirmButton = driver.findElement(By.xpath("//input[@value='confirm']"));
        confirmButton.click();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Alert javascriptConfirm = driver.switchTo().alert();
        javascriptConfirm.accept();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        javascriptConfirm = driver.switchTo().alert();
        javascriptConfirm.accept();

    }
}

 

内存对齐:本机宽度---也就是进行磁盘划分时的切割单个内存单元的大小,也就是对齐宽度寻址花费的时间==》降低寻址次数,数据单元大>也就是内存和效率的互换内存分配时,一个数据总是会尽量不被切开到多个地址单元中如图所示,紫色 ...