여기 내 테스트가 있습니다.레일 오이 카피 바라 ID/클래스 선택
When(/^the admin user broadcasts "([^"]*)" to the notification feed$/) do |userBroadcast|
visit('/broadcasts/new.html')
fill_in('.nifty_form', with: userBroadcast)
click_button('Broadcast')
end
내 new.html.erb에 추가 한 아래 볼 수있는 '멋진 형태'라는 클래스.
<h1>New broadcast</h1>
<%= form_for(@broadcast) do |f| %>
<% if @broadcast.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@broadcast.errors.count, "error") %> prohibited this broadcast from being saved:</h2>
<ul>
<% @broadcast.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= hidden_field_tag 'page', @current_page %>
<div id="broadcast-area" class="main-input-area">
<p>
<%= f.text_area :content, cols: "100%", rows: "10", class: 'nifty-form',
title: "Broadcast text goes here", autofocus: 'autofocus'%>
</p>
<div id="url-part">
<%= link_to("Shortens URL",
id: "split-arrow",
title: "Press this to shorten the URL") %>
<%= text_field_tag :shorten_url, nil,
title: "Enter URL that you wish to shorten",
size: "50%" %>
</div>
<br/>
<div id="">
<%= f.submit 'Broadcast', confirm: 'Do you really want to broadcast?' %> |
<%= link_to 'Back', broadcasts_path(page: @current_page) %>
</div>
</div>
그러나 어떤 이유로, 나는 결과를 얻을 : 내가 렌더링 된 페이지의 소스 조회 한
Unable to find field "nifty_form" (Capybara::ElementNotFound)
을하고는 다음과 같다 :
<textarea cols="100%" rows="1o" class="nifty_form" title="Broadcast text goes here" autofocus="autofocus" name="broadcast[content]" id="broadcast_content" style="z-index: auto; position: relative; line-height: normal; font-size: 10.6667px; transition: none; background: transparent !important;" data-gramm="true" data-txt_gramm_id="b763ea7b-2eef-d3c8-b750-a085d2c9ce80" data-gramm_id="b763ea7b-2eef-d3c8-b750-a085d2c9ce80" spellcheck="false" data-gramm_editor="true"></textarea>
그래서이있다보고 렌더링 된 페이지의 ID 그 ID로 테스트를 작성하기로 결정했습니다.
그러나 다시 한번 나는 모든 사업부의 클래스의 카피 바라 볼 수있는 인쇄 할 수있는 방법이 있나요
Unable to find field "broadcast_content" (Capybara::ElementNotFound)
같은 오류 메시지와 함께 왼쪽 무엇입니까? 이 문제를 어떻게 디버깅 할 수 있습니까? 버튼을 클릭 한 후 Cappybara가 링크를 따라 간다는 가정하에 나는 맞습니까? 그리고 그 세션은 살아 있니?
ID가 튀어 나와 떨어져 아마 더 좋을 것 같아 페이지에없는 고유 한 이후 있지만, 나는 더 붙여 넣은 내 erb.html 파일을보십시오. – Definity
@Definity 텍스트 영역이 실제로 페이지에 표시되지 않고 JS 위젯으로 대체되는 것처럼 들립니다. 그럴까요? 그렇다면 텍스트 영역이 아닌 위젯 요소와 상호 작용해야합니다. –