我要做的是从 Xcode 登录到一个网站。我正在使用 JavaScript 和 DOM 与网站进行通信。这是我的问题。我可以在网站上输入用户名和密码,然后提交该表格,它会让我登录,但我不知道该怎么做是查看密码是否有效。
如果密码无效,网站上会显示“无法登录”。
这就是我到目前为止所拥有的
-(IBAction)Login:(id)sender {
stud_pass = Username.text;
password1 = Password.text;
//Puts the 2 NSStrings into the websites text fields
[webView stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"document.getElementById('stud_pass').value = ('%@');", stud_pass]];
[webView stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"document.getElementById('password1').value = ('%@');", password1]];
//Sends the form
[webView stringByEvaluatingJavaScriptFromString:@"document.forms[0].submit();"];
//See if login was sucsessfull
if (
} else {
}
}
这就是我卡住的地方,我不知道如何让 webview 告诉 xcode 登录不成功,然后基于该让 xcode 有一定的输出。