mardi 24 octobre 2017

No method error for Capybara

I want to add a tag to a tag field. To fill the tag field, I have to add ',', or hit enter with a tag name, for example, "Ezgi,". I wrote these steps for it.

When(/^I enter "([^"]*)" on Label field$/) do |arg1|
    within('.x-anchor-form-item', :text=>'Label') do
        find('.x-tagfield-body').click
        fill_in('', :with=>arg1)
    end
    if page.has_css?('ul', :text=>arg1) then
        within('ul',:text=>arg1) do 
            find('li', :text=>arg1).click
        end 
    else
        within('.x-anchor-form-item', :text=>'Label') do
            find('.x-tagfield-body').native_send_keys(:enter)
        end
        within('.x-window-resizable', match: :first) do 
            find_all('a', :text=>'Save')[1].click
        end
        within('.x-anchor-form-item', :text=>'Label') do
            find('.x-form-text-wrap.x-form-text-wrap-default').click
            fill_in('', :with=>arg1)
        end
        within('ul',:text=>arg1) do 
            find('li', :text=>arg1).click
        end 
    end
end

I tried to write so many classes to fill the field, but that didn't work. For the 11th step, I viewed a message like this:

undefined method `native_send_keys' for #<Capybara::Node::Element:0x00000005119270> (NoMethodError)

Does anyone have any idea for this case? Can someone help me?

Aucun commentaire:

Enregistrer un commentaire