我使用黃瓜,紅寶石和硒。我有以下HTML:獲得div元素與硒的文本
<html>
<body>
<div class="breadcrumbtrail" id="breadcrumbtrail">
home
</div>
</body>
</html>
和下面的步驟定義
begin
puts "got to bct step"
bctValue = @driver.find_element(:class_name, "breadcrumbtrail").getText()
puts "got bctValue value of #{bctValue}"
assert(crumb == bctValue, "breadcrumbtrail #{bctValue}, not #{crumb}")
end
我的輸出顯示步驟正在運行;我曾嘗試從div中獲取「innerText」的屬性,這似乎給了我div的名稱。
我試過find_element之後的各種東西 - 這個告訴我undefined method getText
。我應該在ruby步驟定義中使用什麼來獲取該div內的文本?有沒有人有關於此文件的建議?我發現的唯一一條經過了數百條線,許多支持每種語言,這使得我很難找到我需要的東西。