我想設置登錄ID和密碼使用jquery v1.6在phantomjs v2.1.1,但即使設置憑據並單擊提交按鈕後,頁面顯示輸入登錄名稱和密碼。我的憑據頁面上設置正確,我知道這是因爲我正在頁面的截圖(見附件) enter image description here 我已經看到了關於這個問題的在文本框中的值設置不工作在phatomjs2.1.1
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
}
page.open('example.com', function(status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
console.log("success")
}
page.render('home.png');
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
console.log("jquery loaded");
page.evaluate(function() {
$('input[id="login-form-username"]').val("abc");
$('input[id="login-form-password"]').val("adfsdf++");
$(".aui-button").click();
});
page.render('in.png');
phantom.exit();
});
});
我已經在chrome瀏覽器開發者控制檯上轉載了這個問題,在那裏我加載了網頁,然後在上面提到的page.evaluate函數中運行了行。 –
'repduced the issue' - 意思在那裏不起作用? – Vaviloff
是的,有一些我觀察到,jQuery更改文本框中的文本,但它不會更改其html元素,即它也應該更改文本框的值屬性。 –