我試圖單擊頁面上的鏈接並且只能執行第一個。還有四個代碼有相似之處,但它說它找不到其他四個代碼。如何使用Ruby在Watir中查找類似的HTML元素
這是代碼,工程線路:
@browser.div(class:'ms-vb itx').link(:text =>'Rapid Alignment').click
這是四個中的一個不工作:
@browser.div(class:'ms-vb itx').link(:text =>'Design Develop Integrate and Test').click
HTML:
<div class="ms-vb itx" onmouseover="OnItem(this)" CTXName="ctx586" id="1" Field="LinkTitle" Perm="0xb008031061" EventType=""><a onfocus="OnLink(this)" href="asdm.nwie.net/_layouts/15/…; onclick="EditLink2(this,586);return false;" target="_self">Rapid Alignment</a></div>
<div class="ms-vb itx" onmouseover="OnItem(this)" CTXName="ctx586" id="3" Field="LinkTitle" Perm="0xb008031061" EventType=""><a onfocus="OnLink(this)" href="asdm.nwie.net/_layouts/15/…; onclick="EditLink2(this,586);return false;" target="_self">Design Develop Integrate and Test</a></div>
目前尚不清楚,您能否介紹更多 –
因此,網頁上有5個鏈接。所有5個都有類似的源代碼。我試圖點擊它們中的每一個,只能做到第一個,即使我以同樣的方式調用其他4個。第一個鏈接在頁面上顯示爲「快速對齊」,此代碼用於找到鏈接[email protected](class:'ms-vb itx')。link(:text =>'快速對齊')。 。第二個鏈接在頁面上顯示爲「設計開發集成和測試」,此代碼無法找到它[email protected](class:'ms-vb itx')。link(:text =>'Design Develop集成和測試「)。請點擊 – Bhuvana
「不起作用」是什麼意思?沉默失敗?拋出'無法定位元素'錯誤?沒有關聯的HTML,這只是猜測。請編輯問題幷包含HTML。 – orde