Rspec 当相同元素的find工作时,为什么水豚不允许fill_?
当我找到具有Rspec 当相同元素的find工作时,为什么水豚不允许fill_?,rspec,capybara,selector,Rspec,Capybara,Selector,当我找到具有 pry(#<RSpec::Core::ExampleGroup::Nested_1::Nested_2>)> find('input#auto_policy_drivers_attributes_0_last_name') => #<Capybara::Element tag="input" path="/html/body/section/div[1]/form/div[4]/div[2]/div[2]/div[2]/input"> “查找”
pry(#<RSpec::Core::ExampleGroup::Nested_1::Nested_2>)>
find('input#auto_policy_drivers_attributes_0_last_name')
=> #<Capybara::Element tag="input" path="/html/body/section/div[1]/form/div[4]/div[2]/div[2]/div[2]/input">
“查找”使用完整选择器,但“填充”使用字段名、标签或ID
因此在这种情况下,
fill\u in('auto\u policy\u drivers\u attributes\u 0\u last\u name',with'aaa')
find使用完整选择器,但fill\u in使用字段名、标签或ID
因此,在这种情况下,用“aaa”填写('auto\u policy\u drivers\u attributes\u 0\u last\u name')
有效您应该使用
fill_in "the id/name/label of the field you want to fill", :with => "some text"
例如:
fill_in 'user_username', :with => 'john123'
find(:xpath, '//*[@id="username"]')
find
可用于css路径或xpath,具体取决于您的Capybara。默认选择器
,例如:
fill_in 'user_username', :with => 'john123'
find(:xpath, '//*[@id="username"]')
或
你应该使用
fill_in "the id/name/label of the field you want to fill", :with => "some text"
例如:
fill_in 'user_username', :with => 'john123'
find(:xpath, '//*[@id="username"]')
find
可用于css路径或xpath,具体取决于您的Capybara。默认选择器
,例如:
fill_in 'user_username', :with => 'john123'
find(:xpath, '//*[@id="username"]')
或