差異處
這裏顯示兩個版本的差異處。
rf:rf:howtoassertmultipletextnode [2016/07/08 11:19] tony [Problem] |
rf:rf:howtoassertmultipletextnode [2023/06/25 09:48] |
||
---|---|---|---|
行 1: | 行 1: | ||
- | {{tag>RobotFramework}} | ||
- | ====== How to assert multiple text node? ====== | ||
- | ===== Problem ===== | ||
- | 傳統的網頁資料更新,都是透過刷新整頁方式;隨著javascript的普及化,進步到針對dom node刷新。而資料型態如果為遞增的方式,像jenkins build info或是動作執行過程,很可能為了效能不針對整個node刷新,而採用append的方式。透過瀏覽器所提供的Element檢測器,會看到如下圖情況:\\ | ||
- | {{:rf:rf:rf_pre_node_with_mutiple_text.png|}}\\ | ||
- | 一個pre code底下包含了三個text node,當在selenium中使用以下xpath,是無法找到任何批配的節點: | ||
- | <code> | ||
- | //div[contains(text(),'g2')] | ||
- | </code> | ||
- | 本篇文章主要告訴你,如果某個節點資料是動態插入的,該如何透過selenium去做assert。 | ||
- | ===== How to? ===== | ||
- | |||
- | ===== Reference ===== | ||
- | * [[http://stackoverflow.com/questions/5033955/xpath-select-text-node|Stackoverflow - Xpath to select text node]] | ||
- | * [[http://stackoverflow.com/questions/3655549/xpath-containstext-some-string-doesnt-work-when-used-with-node-with-more|Stackoverflow - XPath contains(text(),'some string') doesn't work when used with node with more than one Text subnode]] | ||
- | |||
- | ===== ===== | ||
- | ---- | ||
- | \\ | ||
- | ~~DISQUS~~ |