0
我正在爲React前端應用程序編寫測試。 其中一項測試必須檢查從服務器返回值的方式。 也就是說,我有以下跨度:使用webdriverio從React包裹的跨度中獲取文本
<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