2017-06-01 5 views
0

分度器を使用して角度アプリケーションでE2Eを実行しています。トグルボタンのスクリプトを書く方法。分度器のオン/オフボタンを切り替える方法

<span class="bootstrap-switch-handle-on bootstrap-switch-primary" style="width: 41px;">ON</span> 
<span class="bootstrap-switch-label" style="width: 41px;">&nbsp;</span> 
<span class="bootstrap-switch-handle-off bootstrap-switch-default" style="width: 41px;">OFF</span> 

答えて

0

あなたのページのDOMを推測することはできません。まず、xpathを使用しないでください。分度器のIMHO byは小文字にする必要があります。

スパン変更の要素クラスをクリックした後であるとします。

多分そのようにかなった方法を試してください。

const button = element(by.css('span.bootstrap-switch-primary')); 
button.getAttribute('class').then((classes) => { 
    if (classes.indexOf('bootstrap-switch-handle-on') === -1) { 
     return button.click(); 
    } 
} 
関連する問題