diff --git a/test/SeleniumZhanShenchen/src/Test/test.java b/test/SeleniumZhanShenchen/src/Test/test.java new file mode 100644 index 0000000..7d068ee --- /dev/null +++ b/test/SeleniumZhanShenchen/src/Test/test.java @@ -0,0 +1,19 @@ +package Test; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; + +import nor.RecoverLostPassword; +import nor.SignIn; +import nor.VisitorPortal; +import nor_Courses.CreateNewCoursePortal; +import nor_Courses.ExtendDeadline; +import nor_Courses.PostNewLabAssignment; + +public class test { + public static void main(String[] args) { + System.setProperty("webdriver.chrome.driver","F:\\chromedriver.exe"); + WebDriver webDriver = new ChromeDriver(); + webDriver.get("http://118.25.96.118/nor/"); + } +} diff --git a/test/SeleniumZhanShenchen/src/nor/RecoverLostPassword.java b/test/SeleniumZhanShenchen/src/nor/RecoverLostPassword.java new file mode 100644 index 0000000..272c79d --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor/RecoverLostPassword.java @@ -0,0 +1,35 @@ +package nor; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +//17 +public class RecoverLostPassword { + public static WebDriver webDriver; + //初始化webDriver 打开网页 + public void InitDriver() { + System.setProperty("webdriver.chrome.driver","F:\\chromedriver.exe"); + webDriver = new ChromeDriver(); + webDriver.get("http://118.25.96.118/nor"); + webDriver.manage().window().maximize(); + } + //找回密码脚本 + public void recpwdScript(String email) { + WebElement reca = webDriver.findElement(By.xpath("/html/body/div[1]/div[2]/div/div/form/a")); + reca.click(); + webDriver.switchTo(); + WebElement emailinput = webDriver.findElement(By.name("email")); + emailinput.sendKeys(email); + WebElement recover = webDriver.findElement(By.className("btn-primary")); + recover.submit(); + webDriver.switchTo(); + WebElement alert = webDriver.findElement(By.className("alert-danger")); + System.out.println(alert.getText()); + } + public static void main(String[] args) { + RecoverLostPassword recoverlostpassword = new RecoverLostPassword(); + recoverlostpassword.InitDriver(); + recoverlostpassword.recpwdScript(""); + } +} diff --git a/test/SeleniumZhanShenchen/src/nor/SignIn.java b/test/SeleniumZhanShenchen/src/nor/SignIn.java new file mode 100644 index 0000000..7d7f9f0 --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor/SignIn.java @@ -0,0 +1,39 @@ +package nor; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +//26 +public class SignIn { + public static WebDriver webDriver; + //初始化webDriver 打开网页 + public void InitDriver() { + System.setProperty("webdriver.chrome.driver","F:\\chromedriver.exe"); + webDriver = new ChromeDriver(); + webDriver.get("http://118.25.96.118/nor/"); + webDriver.manage().window().maximize(); + } + //登录脚本 + public void loginScript(String username,String password) { + WebElement user = webDriver.findElement(By.name("user")); + user.isDisplayed(); + WebElement passwd = webDriver.findElement(By.name("password")); + passwd.isDisplayed(); + WebElement loginBtn = webDriver.findElement(By.className("btn-primary")); + loginBtn.isDisplayed(); + user.sendKeys(username); + passwd.sendKeys(password); +// user.sendKeys(Keys.chord(Keys.CONTROL + "a")); + loginBtn.click(); + webDriver.switchTo();//切换窗口 + WebElement loginInfo = webDriver.findElement(By.className("form-inline")); + System.out.println(loginInfo.getText()); + } + public static void main(String[] args) { + // TODO Auto-generated method stub + SignIn signin = new SignIn(); + signin.InitDriver(); + signin.loginScript("1404325791@qq.com","64566325cc"); + } +} \ No newline at end of file diff --git a/test/SeleniumZhanShenchen/src/nor/VisitorPortal.java b/test/SeleniumZhanShenchen/src/nor/VisitorPortal.java new file mode 100644 index 0000000..9167c71 --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor/VisitorPortal.java @@ -0,0 +1,29 @@ +package nor; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +//16 +public class VisitorPortal { + public static WebDriver webDriver; + //初始化webDriver 打开网页 + public void InitDriver() { + System.setProperty("webdriver.chrome.driver","F:\\chromedriver.exe"); + webDriver = new ChromeDriver(); + webDriver.get("http://118.25.96.118/nor/"); + webDriver.manage().window().maximize(); + } + //访客门户 + public void visitorPortalScript() { + WebElement visitor = webDriver.findElement(By.xpath("//*[@id=\"navbarColor02\"]/ul/li[2]/a")); + visitor.click(); + WebElement files = webDriver.findElement(By.xpath("/html/body/div/div[2]/span/a")); + files.click(); + } + /*public static void main(String[] args) { + VisitorPortal visitorPortal = new VisitorPortal(); + visitorPortal.InitDriver(); + visitorPortal.visitorPortalScript(); + }*/ +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses/AcceptStudents.java b/test/SeleniumZhanShenchen/src/nor_Courses/AcceptStudents.java new file mode 100644 index 0000000..95047f7 --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses/AcceptStudents.java @@ -0,0 +1,25 @@ +package nor_Courses; + + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor.SignIn; +// 6 +public class AcceptStudents { + public WebDriver webDriver = SignIn.webDriver; + //批准加入脚本 + public void acceptScript() { + webDriver.switchTo(); + WebElement accept = webDriver.findElement(By.xpath("/html/body/div/div[2]/div/a[1]")); + accept.click(); + } + /*public static void main(String[] args) { + SignIn signIn = new SignIn(); + signIn.InitDriver(); + signIn.loginScript("1404325791@qq.com", "64566325cc"); + AcceptStudents students = new AcceptStudents(); + students.acceptScript(); + }*/ +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses/CreateNewCoursePortal.java b/test/SeleniumZhanShenchen/src/nor_Courses/CreateNewCoursePortal.java new file mode 100644 index 0000000..b0e73fd --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses/CreateNewCoursePortal.java @@ -0,0 +1,45 @@ +package nor_Courses; + +import java.util.List; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + + +import nor.SignIn; +//21 +public class CreateNewCoursePortal { + public WebDriver webDriver = SignIn.webDriver; + //新建course脚本 + public void createScript(String name1,String code1,String url1,String academic1,String faculty1) { + webDriver.switchTo(); + WebElement name = webDriver.findElement(By.name("name")); + name.sendKeys(name1); + WebElement code = webDriver.findElement(By.name("code")); + code.sendKeys(code1); + WebElement url = webDriver.findElement(By.name("url")); + url.sendKeys(url1); + WebElement academic = webDriver.findElement(By.name("academic")); + academic.sendKeys(academic1); + WebElement faculty = webDriver.findElement(By.name("faculty")); + faculty.sendKeys(faculty1); + List elements = webDriver.findElements(By.name("verify")); + for(WebElement radio:elements) { + boolean flag = radio.isSelected(); + if (flag==false) { + radio.click(); + break; + } + } + WebElement create = webDriver.findElement(By.xpath("/html/body/div/div[2]/form/input[11]")); + create.submit(); + } + public static void main(String[] args) { + SignIn signin = new SignIn(); + signin.InitDriver(); + CreateNewCoursePortal cPortal = new CreateNewCoursePortal(); + signin.loginScript("1404325791@qq.com","64566325cc"); + cPortal.createScript("test3", "3", "", "2020", "2"); + } +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses/EditAssignmentName.java b/test/SeleniumZhanShenchen/src/nor_Courses/EditAssignmentName.java new file mode 100644 index 0000000..e2c8d18 --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses/EditAssignmentName.java @@ -0,0 +1,34 @@ +package nor_Courses; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor.SignIn; + +public class EditAssignmentName { + + public WebDriver webDriver = SignIn.webDriver; + public void editAssignmentNameScript(String number,String title1) { + WebElement course = webDriver.findElement(By.xpath("/html/body/div/div[1]/a["+number+"]/div")); + course.click(); + webDriver.switchTo(); + WebElement edit = webDriver.findElement(By.xpath("/html/body/div[2]/div[2]/div/span/span/a[1]")); + edit.click(); + webDriver.switchTo(); + WebElement title = webDriver.findElement(By.name("title")); + title.clear(); + title.sendKeys(title1); + WebElement type = webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/form/input[10]")); + type.click(); + WebElement submit = webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/form/input[12]")); + submit.click(); + } + public static void main(String[] args) { + SignIn signIn = new SignIn(); + signIn.InitDriver(); + signIn.loginScript("1404325791@qq.com", "64566325cc"); + EditAssignmentName editAssignmentName = new EditAssignmentName(); + editAssignmentName.editAssignmentNameScript("5","test2"); + } +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses/ExtendDeadline.java b/test/SeleniumZhanShenchen/src/nor_Courses/ExtendDeadline.java new file mode 100644 index 0000000..01cfa7f --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses/ExtendDeadline.java @@ -0,0 +1,35 @@ +package nor_Courses; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor.SignIn; +//11 +public class ExtendDeadline { + public WebDriver webDriver = SignIn.webDriver; + //延迟时间脚本 + public void extendDeadlineScript(String number, String date1, String time1) { + WebElement course = webDriver.findElement(By.xpath("/html/body/div/div[1]/a["+number+"]/div")); + course.click(); + webDriver.switchTo(); + WebElement extend = webDriver.findElement(By.xpath("/html/body/div[2]/div[2]/div/span/span/a[3]")); + extend.click(); + webDriver.switchTo(); + WebElement date = webDriver.findElement(By.name("date")); + date.sendKeys(date1); + WebElement time = webDriver.findElement(By.name("time")); + time.sendKeys(time1); + WebElement extendfor = webDriver.findElement(By.xpath("//*[@id=\"frm\"]/input[5]")); + extendfor.click(); + WebElement submit = webDriver.findElement(By.xpath("/html/body/div[3]/div[2]/div/button[1]")); + submit.click(); + } + public static void main(String[] args) { + SignIn signIn = new SignIn(); + signIn.InitDriver(); + signIn.loginScript("1404325791@qq.com", "64566325cc"); + ExtendDeadline extendDeadline = new ExtendDeadline(); + extendDeadline.extendDeadlineScript("5", "0020200331", "2200"); + } +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses/LabReportResultPosting.java b/test/SeleniumZhanShenchen/src/nor_Courses/LabReportResultPosting.java new file mode 100644 index 0000000..07df515 --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses/LabReportResultPosting.java @@ -0,0 +1,36 @@ +package nor_Courses; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor.SignIn; +//14 +public class LabReportResultPosting { + public WebDriver webDriver = SignIn.webDriver; + //打分 + public void labReportResultPostingScript(String number,String marks1,String feedback1) {//课程的位置 分数 评论 + webDriver.switchTo(); + WebElement course = webDriver.findElement(By.xpath("/html/body/div/div[1]/a["+number+"]/div")); + course.click(); + webDriver.switchTo(); + WebElement view = webDriver.findElement(By.xpath("/html/body/div[2]/div[2]/div/span/span/a[2]")); + view.click(); + WebElement MarkSubmission = webDriver.findElement(By.xpath("//*[@id=\"menu1\"]/k/div/span/button")); + MarkSubmission.click(); + webDriver.switchTo(); + WebElement marks = webDriver.findElement(By.name("marks")); + marks.sendKeys(marks1); + WebElement feedback = webDriver.findElement(By.name("feedback")); + feedback.sendKeys(feedback1); + WebElement submit = webDriver.findElement(By.xpath("/html/body/div[4]/div[2]/div/button[1]/span")); + submit.click(); + } + /*public static void main(String[] args) { + SignIn signIn = new SignIn(); + signIn.InitDriver(); + signIn.loginScript("1404325791@qq.com", "64566325cc"); + LabReportResultPosting labReportResultPosting = new LabReportResultPosting(); + labReportResultPosting.labReportResultPostingScript("6", "90", "feedback1"); + }*/ +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses/PostNewLabAssignment.java b/test/SeleniumZhanShenchen/src/nor_Courses/PostNewLabAssignment.java new file mode 100644 index 0000000..79bf98c --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses/PostNewLabAssignment.java @@ -0,0 +1,46 @@ +package nor_Courses; + +import java.util.List; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor.SignIn; +//14 +public class PostNewLabAssignment { + public WebDriver webDriver = SignIn.webDriver; + //新建Assignment脚本 + public void createAsscript(String number,String date1,String deadlinetime1,String title1,String instructions1,String marks1) { + WebElement classname = webDriver.findElement(By.xpath("/html/body/div[1]/div[1]/a["+number+"]/div")); + classname.click(); + webDriver.switchTo(); + WebElement date = webDriver.findElement(By.id("date")); + date.sendKeys(date1); + WebElement deadlinetime = webDriver.findElement(By.name("deadlinetime")); + deadlinetime.sendKeys(deadlinetime1); + WebElement title = webDriver.findElement(By.name("title")); + title.sendKeys(title1); + WebElement instructions = webDriver.findElement(By.name("instructions")); + instructions.sendKeys(instructions1); + WebElement marks = webDriver.findElement(By.name("marks")); + marks.sendKeys(marks1); + List elements = webDriver.findElements(By.name("type")); + for(WebElement radio:elements) { + boolean flag = radio.isSelected(); + if (flag==false) { + radio.click(); + break; + } + } + WebElement post = webDriver.findElement(By.className("btn-primary")); + post.submit(); + } + public static void main(String[] args) { + SignIn signIn = new SignIn(); + signIn.InitDriver(); + signIn.loginScript("1404325791@qq.com", "64566325cc"); + PostNewLabAssignment postNewLabAssignment = new PostNewLabAssignment(); + postNewLabAssignment.createAsscript("5","0020200412", "22:00", "test02", "111", "100"); + } +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses/Remarking.java b/test/SeleniumZhanShenchen/src/nor_Courses/Remarking.java new file mode 100644 index 0000000..18359e2 --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses/Remarking.java @@ -0,0 +1,38 @@ +package nor_Courses; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor.SignIn; +//17 +public class Remarking { + public WebDriver webDriver = SignIn.webDriver; + //重新打分 + public void remarkScript(String number,String marks1,String feedback1) {//课程的位置 分数 评论 + webDriver.switchTo(); + WebElement course = webDriver.findElement(By.xpath("/html/body/div/div[1]/a["+number+"]/div")); + course.click(); + webDriver.switchTo(); + WebElement view = webDriver.findElement(By.xpath("/html/body/div[2]/div[2]/div/span/span/a[2]")); + view.click(); + WebElement ReMarkingRequests = webDriver.findElement(By.xpath("/html/body/div[2]/div/ul/li[3]/a")); + ReMarkingRequests.click(); + webDriver.switchTo(); + WebElement remark = webDriver.findElement(By.xpath("//*[@id=\"menu3\"]/k/div/span/button")); + remark.click(); + WebElement marks = webDriver.findElement(By.name("marks")); + marks.sendKeys(marks1); + WebElement feedback = webDriver.findElement(By.name("feedback")); + feedback.sendKeys(feedback1); + WebElement submit = webDriver.findElement(By.xpath("/html/body/div[4]/div[2]/div/button[1]/span")); + submit.click(); + } + public static void main(String[] args) { + SignIn signIn = new SignIn(); + signIn.InitDriver(); + signIn.loginScript("1404325791@qq.com", "64566325cc"); + Remarking remarking = new Remarking(); + remarking.remarkScript("6", "100", "abc"); + } +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses_Students/FindCourse.java b/test/SeleniumZhanShenchen/src/nor_Courses_Students/FindCourse.java new file mode 100644 index 0000000..9094a13 --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses_Students/FindCourse.java @@ -0,0 +1,30 @@ +package nor_Courses_Students; + + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor_students.SignInStudents; +//6 + +public class FindCourse { + public WebDriver webDriver = SignInStudents.webDriver; + //通过code寻找和申请加入课程 + public void findCourseScript(String code) {//课程code + webDriver.switchTo(); + WebElement search = webDriver.findElement(By.name("search")); + search.sendKeys(code); + WebElement searchbtn = webDriver.findElement(By.xpath("/html/body/div[2]/div[2]/form/div/div[2]/input")); + searchbtn.click(); + WebElement join = webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div[1]/a")); + join.click(); + } + /*public static void main(String[] args) { + SignInStudents signInStudents = new SignInStudents(); + signInStudents.InitDriver(); + signInStudents.loginStudentsScript("201632110128", ">[@+cO03"); + FindCourse findCourse = new FindCourse(); + findCourse.findCourseScript("3"); + }*/ +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses_Students/LabReportSubmission.java b/test/SeleniumZhanShenchen/src/nor_Courses_Students/LabReportSubmission.java new file mode 100644 index 0000000..3c57be3 --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses_Students/LabReportSubmission.java @@ -0,0 +1,34 @@ +package nor_Courses_Students; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor_students.SignInStudents; +//19:52 20:21 +public class LabReportSubmission { + public WebDriver webDriver = SignInStudents.webDriver; + //提交报告 + public void subLPScript(String number,String name1,String file1) {//课程的位置 标题 文件路径 + webDriver.switchTo(); + WebElement course = webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div["+number+"]/a[1]")); + course.click(); + webDriver.switchTo(); + WebElement submitLP = webDriver.findElement(By.className("btn-info")); + submitLP.click(); + webDriver.switchTo(); + WebElement title = webDriver.findElement(By.name("title")); + title.sendKeys(name1); + WebElement inputfile = webDriver.findElement(By.name("attachment1")); + inputfile.sendKeys(file1); + WebElement submit = webDriver.findElement(By.xpath("/html/body/div[2]/div/div[2]/input[3]")); + submit.click(); + } + /*public static void main(String[] args) { + SignInStudents signInStudents = new SignInStudents(); + signInStudents.InitDriver(); + signInStudents.loginStudentsScript("201632110128", ">[@+cO03"); + LabReportSubmission labReportSubmission = new LabReportSubmission(); + labReportSubmission.subLPScript("4", "test1", "D:/bjg.txt"); + }*/ +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses_Students/RequestRemarking.java b/test/SeleniumZhanShenchen/src/nor_Courses_Students/RequestRemarking.java new file mode 100644 index 0000000..1674739 --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses_Students/RequestRemarking.java @@ -0,0 +1,30 @@ +package nor_Courses_Students; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor_students.SignInStudents; +//11 +public class RequestRemarking { + public WebDriver webDriver = SignInStudents.webDriver; + //申请重新打分 + public void requestRemarkScript(String number,String reason) {//课程的位置 理由 + webDriver.switchTo(); + WebElement course = webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div["+number+"]/a[1]")); + course.click(); + WebElement MarkedSubmissions = webDriver.findElement(By.xpath("/html/body/div[3]/div[1]/ul/li[4]/a")); + MarkedSubmissions.click(); + WebElement requestRemark = webDriver.findElement(By.xpath("//*[@id=\"menu4\"]/k/div/button")); + requestRemark.click(); + webDriver.switchTo().alert().sendKeys(reason); + webDriver.switchTo().alert().accept(); + } + /*public static void main(String[] args) { + SignInStudents signInStudents = new SignInStudents(); + signInStudents.InitDriver(); + signInStudents.loginStudentsScript("201632110128", ">[@+cO03"); + RequestRemarking requestRemarking = new RequestRemarking(); + requestRemarking.requestRemarkScript("4","123"); + }*/ +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses_Students/StudentsGroup.java b/test/SeleniumZhanShenchen/src/nor_Courses_Students/StudentsGroup.java new file mode 100644 index 0000000..cb4dafd --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses_Students/StudentsGroup.java @@ -0,0 +1,31 @@ +package nor_Courses_Students; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor_students.SignInStudents; +//13 +public class StudentsGroup { + public WebDriver webDriver = SignInStudents.webDriver; + public void createGroupScript(String number, String name1) { + webDriver.switchTo(); + WebElement course = webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div["+number+"]/a[1]")); + course.click(); + webDriver.switchTo(); + WebElement group = webDriver.findElement(By.className("btn-primary")); + group.click(); + webDriver.switchTo(); + WebElement groupname = webDriver.findElement(By.name("name")); + groupname.sendKeys(name1); + WebElement submit = webDriver.findElement(By.xpath("/html/body/div[6]/div[2]/div/button[1]/span")); + submit.click(); + } + /*public static void main(String[] args) { + SignInStudents signInStudents = new SignInStudents(); + signInStudents.InitDriver(); + signInStudents.loginStudentsScript("201632110128", ">[@+cO03"); + StudentsGroup studentsGroup = new StudentsGroup(); + studentsGroup.createGroupScript("4", "group4"); + }*/ +} diff --git a/test/SeleniumZhanShenchen/src/nor_Courses_Students/ViewAssignmentGrading.java b/test/SeleniumZhanShenchen/src/nor_Courses_Students/ViewAssignmentGrading.java new file mode 100644 index 0000000..d7b4fb4 --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_Courses_Students/ViewAssignmentGrading.java @@ -0,0 +1,28 @@ +package nor_Courses_Students; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import nor_students.SignInStudents; +//9 +public class ViewAssignmentGrading { + public WebDriver webDriver = SignInStudents.webDriver; + //看分数 + public void viewAssGradeScript(String number) {//课程的位置 + webDriver.switchTo(); + WebElement course = webDriver.findElement(By.xpath("/html/body/div[2]/div[1]/div["+number+"]/a[1]")); + course.click(); + WebElement MarkedSubmissions = webDriver.findElement(By.xpath("/html/body/div[3]/div[1]/ul/li[4]/a")); + MarkedSubmissions.click(); + WebElement grade = webDriver.findElement(By.xpath("//*[@id=\"menu4\"]/k/div/b")); + System.out.println(grade.getText()); + } + /*public static void main(String[] args) { + SignInStudents signInStudents = new SignInStudents(); + signInStudents.InitDriver(); + signInStudents.loginStudentsScript("201632110128", ">[@+cO03"); + ViewAssignmentGrading viewAssignmentGrading = new ViewAssignmentGrading(); + viewAssignmentGrading.viewAssGradeScript("4"); + }*/ +} diff --git a/test/SeleniumZhanShenchen/src/nor_students/SignInStudents.java b/test/SeleniumZhanShenchen/src/nor_students/SignInStudents.java new file mode 100644 index 0000000..029902f --- /dev/null +++ b/test/SeleniumZhanShenchen/src/nor_students/SignInStudents.java @@ -0,0 +1,38 @@ +package nor_students; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; + +public class SignInStudents { + public static WebDriver webDriver; + //初始化webDriver 打开网页 + public void InitDriver() { + System.setProperty("webdriver.chrome.driver","F:\\chromedriver.exe"); + webDriver = new ChromeDriver(); + webDriver.get("http://118.25.96.118/nor/"); + webDriver.manage().window().maximize(); + } + //登录脚本 + public void loginStudentsScript(String username,String password) { + webDriver.findElement(By.className("btn-primary")); + WebElement user = webDriver.findElement(By.name("user")); + user.isDisplayed(); + WebElement passwd = webDriver.findElement(By.name("password")); + passwd.isDisplayed(); + WebElement loginBtn = webDriver.findElement(By.className("btn-primary")); + loginBtn.isDisplayed(); + user.sendKeys(username); + passwd.sendKeys(password); + loginBtn.click(); + webDriver.switchTo();//切换窗口 + WebElement loginInfo = webDriver.findElement(By.className("form-inline")); + System.out.println(loginInfo.getText()); + } + /*public static void main(String[] args) { + SignInStudents signInStudents = new SignInStudents(); + signInStudents.InitDriver(); + signInStudents.loginStudentsScript("201631900128", ">[@+cO03"); + }*/ +}