phantom.js坚持选择下一个元素



我正在尝试使用phantom.js在此页面上进行某些页面自动化:https://reserve.apple.com/gb/en_gb/reserve/reserve/iphone

我知道如何使用document.getElementById('store') = "R363"选择第一个选项。但是似乎我选择了第一个选项后,原始页面的DOM元素将会改变,我不知道如何使用phantom.js

实现这一目标。

而不是使用 document.getElementById('store') = "R363"尝试使用jQuery这样的jQuery:

var page = require('webpage').create(); 
// open the page
page.open('https://reserve.apple.com/GB/en_GB/reserve/iPhone', function() {
    //inject jQuery
    page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
        // run the following code in the context of the page
        page.evaluate(function() {
            // change the value of the combobox
            $("#store").val( newval );
            // do stuff in the page
        });
        phantom.exit()
    });
});

最新更新