Se(10)---上传文件

package test;


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 lesson9 {


@Test

public void test() throws InterruptedException{

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

WebDriver dr = new ChromeDriver();

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

        dr.get("http://www.layui.com/demo/upload.html");

        Thread.sleep(3000);

        

        //上传文件

WebElement el1 = dr.findElement(By.id("test"));

el1.sendKeys("d:/1.jpg");

//dr.quit();

}

}