casperjs を使用してページ上のすべての jquery ui タブを取得し、それぞれをクリックしています。問題は、タブが動的に読み込まれ、「読み込み中...」状態から切り替わらないことです。私はキャスパーwait()
関数とwaitWhileSelector(
) 関数を使ってみましたが、どちらもうまくいかないようです:
function getActiveTab () {
var active_tab = $('#tabs>ul').find('li.ui-tabs-selected').text();
console.log("Active tab: " + active_tab);
return active_tab;
}
function clickTabs (tabs) {
this.each(tabs, function(casper, tab_name, i){
var child_number = i + 1;
var tab_selector = "#tabs>ul>li:nth-child(" + child_number + ")>a";
console.log(tab_selector);
// this.thenClick(tab_selector).waitWhileSelector('#tabs>ul>li.ui-state-processing', function(){
this.thenClick(tab_selector, function(){
var this_tab = this.evaluate(getActiveTab);
});
});
}
最初のタブでは機能しているように見えますが (ページの読み込み時に読み込まれるため)、残りはすべて「読み込み中」を返します。
------ snip passed tests ------
#tabs>ul>li:nth-child(1)>a
#tabs>ul>li:nth-child(2)>a
#tabs>ul>li:nth-child(3)>a
#tabs>ul>li:nth-child(4)>a
#tabs>ul>li:nth-child(5)>a
#tabs>ul>li:nth-child(6)>a
#tabs>ul>li:nth-child(7)>a
#tabs>ul>li:nth-child(8)>a
#tabs>ul>li:nth-child(9)>a
remote message caught: Active tab: Host Allocation
Page Error: TypeError: 'undefined' is not a function (evaluating '$('#disk_pools_table').dataTable')
remote message caught: Active tab: Loadingâ¦
Page Error: TypeError: 'undefined' is not a function (evaluating '$('#vvol_groups_table').dataTable')
remote message caught: Active tab: Loadingâ¦
Page Error: TypeError: 'undefined' is not a function (evaluating '$('#arrayCablesTable').dataTable')
remote message caught: Active tab: Loadingâ¦
remote message caught: Active tab: Loadingâ¦
Page Error: TypeError: 'undefined' is not a function (evaluating '$('#fa_information_table').dataTable')
Page Error: TypeError: 'undefined' is not a function (evaluating '$('#zoning_table').dataTable')
remote message caught: Active tab: Loadingâ¦
Page Error: TypeError: 'undefined' is not a function (evaluating '$('#pool_mismatch_table').dataTable')
remote message caught: Active tab: Loadingâ¦
Page Error: TypeError: 'undefined' is not a function (evaluating '$('#other_information_table').dataTable')
remote message caught: Active tab: Loadingâ¦
Page Error: TypeError: 'undefined' is not a function (evaluating '$('#arrayIPs').dataTable')
remote message caught: Active tab: Loadingâ¦
FAIL 12 tests executed in NaNs, 11 passed, 1 failed.
waitWhileSelector を使用すると、最初のクリック後にタイムアウトします。ほとんどのタブは、dataTables オブジェクトを含むスクリプト タグを動的に読み込みますが、テーブル オブジェクトがまったく読み込まれないか、datatables ライブラリが読み込まれないように見えますか? そのライブラリを evaluate メソッドに挿入する必要がありますか、それともページ内のタグがそれを引き込む必要がありますか?
このテストで何が起こっているのかを特定するための助けをいただければ幸いです。