因此,我的灯箱已被识别,我如何访问其中的内容?
当我输入:
within("div.fancybox-wrap.fancybox-desktop.fancybox-type-iframe.fancybox-opened") do
within(:xpath, "//table[@id='small_calendar'][0]") do
page.find('td', :text => '5').click
end
end
有关
<table id="small_calendar">
我明白了......
Unable to find xpath "//table[@id='small_calendar'][0]" (Capybara::Element
NotFound)
修改了搜索....
sleep(10)
within("div.fancybox-wrap.fancybox-desktop.fancybox-type-iframe.fancybox-opened") do
within_frame('fancybox-frame') do
#within(:xpath, ".//table[@id='small_calendar'][0]") do
page.find(:xpath, ".//table[@id='small_calendar'][0]/td[@text='5']").click
#end
end
end
让我犯这个错误......
findElements execution failed;
Element does not exist in cache (Selenium::WebDriver::Error::StaleElement
ReferenceError)
答案 0 :(得分:1)
如果元素在框架内,则必须使用within_frame
方法明确说明:
within_frame('fancybox-frame') do
within(:xpath, "//table[@id='small_calendar']") do
page.find('td', :text => '5').click
end
end
答案 1 :(得分:0)
知道了!
问题似乎是帧内和xpath不相处。一旦我将其从等式中移除,我就得到了理想的结果。
within_frame('fancybox-frame') do
#within(:xpath, ".//table[@id='small_calendar'][0]") do #chokes
within(all("table[id='small_calendar']").first) do #works!
#page.find(:xpath, ".//table[@id='small_calendar'][0]/td[@text='5']").click #chokes
page.find("td[id='2013_0_6']").click #works!
end
end