반응형
Capybara에서 찾기와 함께 fill_in을 사용하는 방법 (가능한 경우)
다음을 수행하고 싶지만 fill_in의 특성으로 인해 로케이터를 첫 번째 인수로 기대할 수 없습니다.
find(:css, "input[id$='donation_pledge_hundreds']").fill_in :with => "10"
나는 또한 시도했다
element = find(:css, "input[id$='donation_pledge_hundreds']")
fill_in element.<method> , :with => "10"
그러나 fill_in 할 요소를 식별하기 위해 데이터를 반환하는 메서드는 없습니다.
fill_in과 함께 사용하기 위해 정규식을 통해 필드를 찾는 가장 좋은 방법에 대한 아이디어가 있습니까?
메모리에서 이동하면 100 % 정확하지 않을 수 있지만 요소 자체에 대한 참조가 있으면 다음 set
대신 사용할 것이라고 생각합니다 fill_in
.
find(:css, "input[id$='donation_pledge_hundreds']").set("10")
그러나 특정 예의 경우 fill_in
ID를 알고있는 요소를 찾을 수 있어야합니다.
fill_in 'donation_pledge_hundreds', with: "10"
대신 방법, 당신은 반환 브래킷을 사용할 수 있습니다 :name
또는 :id
예를 들어, element = find(:css, "input[id$='donation_pledge_hundreds']") fill_in element[:name], :with => "10"
동일한 접근 방식을 사용할 수 있습니다 select
- select my_type, from: find('select[name$="[type]"]')[:name]
find("input[id$='donation_pledge_hundreds']").set "10"
발견 한 내용을 연결할 수 있다는 점은 주목할 가치가 있습니다.
@modal = find(".modal")
@modal.find('input[name=foo]').set "bar"
element = find(:css, "input[id$='donation_pledge_hundreds']")
element.fill_in with: "10"
fill_in <$id>, :with => 'text you want to fill in'
참고 URL : https://stackoverflow.com/questions/8534365/how-to-use-fill-in-with-find-in-capybara-if-possible
반응형
'development' 카테고리의 다른 글
JPA : 동일한 엔티티 유형의 일대 다 관계를 갖는 방법 (0) | 2020.09.07 |
---|---|
쉘 스크립트의 줄 끝에 세미콜론이 불필요합니까? (0) | 2020.09.07 |
TensorFlow에서 정규화를 추가하는 방법은 무엇입니까? (0) | 2020.09.07 |
MySQL에서 외래 키의 기본? (0) | 2020.09.07 |
App Store 출시시 반드시 증가해야하는 iOS 앱 버전 / 빌드 번호는 무엇입니까? (0) | 2020.09.07 |