phimage/Erik

Website cannot successfully login

jeffreyyu0602 opened this issue · 1 comments

I filled in the username and password and click the submit button, but when I examine the html using browser.currentContent I find out that it still stays at the same page. I am not sure if it's the click() method not working. Am I doing anything wrong? Thanks!

private func submit(_ url: URL, user: String, password: String) {
    browser.visit(url: url) { obj, err in
        if let e = err {
            print("Error: \(e)")
        } else if let doc = obj {
            if let input = doc.querySelectorAll("input[id='ssousername']").first {
                input["value"] = user
            }
            if let input = doc.querySelectorAll("input[id='ssopassword']").first {
                input["value"] = password
            }
            _ = doc.click("button[type='submit']")
            }
    }
    browser.currentContent { (obj, err) -> Void in
        if let e = err {
            print("Error: \(e)")
        } else if let doc = obj {
            print(doc.body!)
        }
    }
}

I found the problem. The website took some time to login. So if I immediately get the content, the html would be the same.