2024全国大学生软件测试web赛道练习题答案
importorg.openqa.selenium.chrome.ChromeDriver;importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.WebElement;importorg.openqa.selenium.By;@SuppressWarnings("unused")publicclassExample{// Mooctest Selenium Example// <!> Check if selenium-standalone.jar is added to build path.publicstaticvoidtest(WebDriver driver){// TODO Test script// eg:driver.get("https://www.baidu.com/")// eg:driver.findElement(By.id("wd"));try{
driver.get("http://120.26.37.204:8088/marks/login");
driver.manage().window().maximize();Thread.sleep(1500);
driver.findElement(By.name("userName")).sendKeys("admin");//账号Thread.sleep(1500);
driver.findElement(By.name("passWord")).sendKeys("123456");//密码Thread.sleep(1500);
driver.findElement(By.id("loginFormBtn")).click();//登录Thread.sleep(1500);
driver.findElement(By.linkText("系统用户管理")).click();//系统用户管理Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[3]/div[2]/div[1]/button")).click();//+号Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[4]/div[2]/form/div[1]/input")).sendKeys("111");Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[4]/div[2]/form/div[2]/input")).sendKeys("111");Thread.sleep(1500);
driver.findElement(By.name("name")).sendKeys("111");//用户名Thread.sleep(1500);
driver.findElement(By.name("age")).sendKeys("20");//年龄Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[4]/div[2]/form/div[5]/input[2]")).click();//女Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[4]/div[2]/form/div[6]/input[2]")).click();//采购员Thread.sleep(1500);
driver.findElement(By.name("phone")).sendKeys("111");Thread.sleep(1500);
driver.findElement(By.name("address")).sendKeys("江苏南京");Thread.sleep(1500);
driver.findElement(By.id("addFormBtn")).click();//提交Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[9]/div[2]/div[2]/button")).click();//知道了Thread.sleep(1500);
driver.findElement(By.name("para2")).sendKeys("111");Thread.sleep(1500);
driver.findElement(By.name("para3")).sendKeys("111");Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[3]/div[1]/div[2]/div[4]/button")).click();//搜索Thread.sleep(1500);
driver.findElement(By.xpath("//*[@id=\"tableShow\"]/table/tbody/tr[1]/td[9]/button[2]")).click();//删除Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[9]/div[2]/div[2]/button[1]")).click();//确认删除Thread.sleep(1500);
driver.findElement(By.linkText("会员等级设置")).click();Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[3]/div[2]/div[1]/button/span")).click();//+号Thread.sleep(1500);
driver.findElement(By.name("name")).sendKeys("钻石");Thread.sleep(1500);
driver.findElement(By.name("total")).sendKeys("1000");Thread.sleep(1500);
driver.findElement(By.name("discount")).sendKeys("0.5");Thread.sleep(1500);
driver.findElement(By.id("addFormBtn")).click();//提交Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[9]/div[2]/div[2]/button")).click();//知道了Thread.sleep(1500);
driver.findElement(By.className("fater-user")).click();Thread.sleep(1500);
driver.findElement(By.id("sessionExit")).click();Thread.sleep(1500);
driver.findElement(By.xpath("/html/body/div[9]/div[2]/div[2]/button[1]")).click();Thread.sleep(1500);}catch(InterruptedException e){// TODO Auto-generated catch block
e.printStackTrace();}}publicstaticvoidmain(String[] args){// Run main function to test your script.System.setProperty("webdriver.chrome.driver","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");WebDriver driver =newChromeDriver();try{test(driver);}catch(Exception e){ e.printStackTrace();}finally{ driver.quit();}}}
本文转载自: https://blog.csdn.net/m0_74014989/article/details/142357822
版权归原作者 Wneosy 所有, 如有侵权,请联系我们删除。
版权归原作者 Wneosy 所有, 如有侵权,请联系我们删除。