|
@@ -254,6 +254,30 @@ func nextPage(wd selenium.WebDriver) []selenium.WebElement {
|
|
|
return buttons
|
|
|
}
|
|
|
|
|
|
+func tryChangePassSure(wd selenium.WebDriver) bool {
|
|
|
+ act, err := wd.ActiveElement()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("find active element\n")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ _, err = act.FindElement(selenium.ByXPATH, "//div[contains(text(), '请尽快修改密码')]")
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("find active element to change pass\n")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ sure, err := act.FindElement(selenium.ByXPATH, "//span[text()='确定']")
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("find active element to change pass sure\n")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ err = tryClick(wd, sure)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("find active element to click\n")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+}
|
|
|
+
|
|
|
func StartOneStudentHandle(usernameText string, passwordText string, realName string) (*selenium.Service, selenium.WebDriver, error) {
|
|
|
|
|
|
var (
|
|
@@ -409,10 +433,23 @@ func StartOneStudentHandle(usernameText string, passwordText string, realName st
|
|
|
}
|
|
|
//time.Sleep(1200 *time.Second)
|
|
|
//return service, wd, errors.New("登录测试")
|
|
|
+
|
|
|
+ time.Sleep(2 * time.Second)
|
|
|
+ tryChangePassSure(wd)
|
|
|
// 进入学生主页
|
|
|
err = wd.WaitWithTimeout(Displayed(selenium.ByXPATH, "//a[text()='去学习']"), time.Duration(config.Conf.Timeout)*time.Second)
|
|
|
if err != nil {
|
|
|
- return service, wd, errors.New(fmt.Sprintf("进入学生主页失败:%v\n", err))
|
|
|
+
|
|
|
+ if !tryChangePassSure(wd) {
|
|
|
+ return service, wd, errors.New(fmt.Sprintf("进入学生主页失败:%v\n", err))
|
|
|
+ }
|
|
|
+ time.Sleep(2 * time.Second)
|
|
|
+ err = wd.WaitWithTimeout(Displayed(selenium.ByXPATH, "//a[text()='去学习']"), time.Duration(config.Conf.Timeout)*time.Second)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("find active element to find page\n")
|
|
|
+ return service, wd, errors.New(fmt.Sprintf("进入学生主页失败:%v\n", err))
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
fmt.Printf("进入学生主页\n")
|
|
|
|