Ruby webdrive在类未引用名称时单击列表中的元素
我正在进行搜索,然后尝试单击从搜索结果返回的名称 如果我搜索Bond,下面是我将在页面上看到的结果Ruby webdrive在类未引用名称时单击列表中的元素,ruby,selenium-webdriver,Ruby,Selenium Webdriver,我正在进行搜索,然后尝试单击从搜索结果返回的名称 如果我搜索Bond,下面是我将在页面上看到的结果 <li class = "resultsItem " data-index ="0"> <div class = "name" data-cid ="d182a061-1afd-4924-b256-035d7e6f34ec" onclick="return true;"> Bond, James </div> <
<li class = "resultsItem " data-index ="0">
<div class = "name" data-cid ="d182a061-1afd-4924-b256-035d7e6f34ec" onclick="return true;">
Bond, James </div>
<a class = "ir icon emailAction" href="mailto:jamesbond@mi6@.com"1</a>
</li>
我不认为名字或文字会起作用。我不喜欢数据cid,但希望它能起作用。
有人有什么想法吗
谢谢
Jeff在与ahwile一起玩过之后,我能够通过代码blow使事情正常工作
element = driver.find_elements (:xpath, "//li @class='resultsItem ']/div")
for item in element
if item.text() == "Bond, James" then
item.click
end
end
谢谢
Jeff在做了一点手脚之后,我找到了元素中的项的答案元素=driver.find_elements(:xpath,//li@class='resultsItem']/div),if item.text()=“Bond,James”然后单击item.click end希望这有助于其他遇到此项的人:)查看此项:
element = driver.find_elements (:xpath, "//li @class='resultsItem ']/div")
for item in element
if item.text() == "Bond, James" then
item.click
end
end