Reactフロントエンドアプリケーションのテストを書いています。 テストの1つは、サーバーから値が返された方法をチェックする必要があります。 はつまり、私は次のスパンを持っている:webdriverioを使ってReact wrapped spanからテキストを取得
<span id='result'>
<!-- our version of react wraps the resulting text by default -->
<span data-reactid>the actual result</span>
</span>
// test.js
getResult() {
let a = browser.getText('#result span');
console.log('a:', a);
} // unfortunately, getting it this way will mean having to rewrite the test once we upgrade to a newer version of React (after 15 is does not do the wrapping anymore)
だから、基本的に..私はによって生成されたスパンのどちらかがIDまたはクラス...または他のを持って反応するようにテキスト値を取得できますかDOM構造の変更がテストを書き直さなければならないというわけではありません。
あなたは 'browser.getText( '#result')'だけを試しましたか? –
はい..しかし、反応はいつもものの周りにをラップするので、私はbrowser.getText( '#result span');を使用しなければなりません。 – JeanAlesi