一、
package day01;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class elementOperator {
public static WebDriver driver;
@BeforeTest
public void setOpen() throws InterruptedException{
//驱动
System.setProperty("webdriver.chrome.driver", "src/test/resources/chromedriver.exe");
driver= new ChromeDriver();
//将窗口最大化
driver.manage().window().maximize();
driver.get("https://test.pxxtech.com/#/login");
Thread.sleep(2000);
}
@Test
public void test() throws InterruptedException{
driver.findElement(By.xpath("//span[text()='账号密码登录']")).click();
Thread.sleep(2000);
driver.findElement(By.id("username")).sendKeys("18705070219");
driver.findElement(By.id("password")).sendKeys("tcp12589");
driver.findElement(By.xpath("//*[@id='root']/div/div[2]/div/form/button")).click();
}
@AfterTest
public void setDown() throws InterruptedException{
Thread.sleep(5000);
//关闭浏览器,关闭驱动
driver.quit();
}
}