I try to do an Selenium-Acceptancetest 'Search Result List' with RSpec spec
- And my Issue is
It should verify the count of a Button "Detail"
I would be happy to get help for start thinking as a coder; i am a manual tester stil.
My Problem now is:
Method Error
Failure/Error: expect(@driver.find_element(:xpath, "//a[contains(text(),'Details')]").to be > 4)
NoMethodError:
undefined method `to' for #<Selenium::WebDriver::Element:0x00000003fd4938>
- Sources:
On my way to resolve the issue I tried to modify this and I found this
But its not working
thanksfully remaining!
my Test File:
# coding: utf-8
puts "this is #{File.basename(__FILE__)}"
extend RSpec::Expectations
extend RSpec::Matchers
describe 'SEL' do
before(:each) do
@driver = loadDriver()
end
after(:each) do
@driver.quit
end
it 'test_Page (SEL)' do
#get the page
...
#do input keyword 'Restaurant'
...
#click submit
...
#(Works!) temp Validation1: Is there a "Btn Details" in SearchResultList?
expect(@driver.find_element(:xpath, "//a[contains(text(),'Details')]").displayed?)
#(Works not!) Validation: Are there more than "5 Btns Detail"
expect(@driver.find_element(:xpath, "//a[contains(text(),'Details')]").to be > 5)
end
end
Update after first answer:
Given I use
expect(@driver.find_elements(:xpath, "//a[contains(text(),'Details')]")).to be > 0
it hits that error:
Failure/Error: expect(@driver.find_elements(:xpath, "//a[contains(text(),'Details')]")).to be > 0
expected: > 0
got: [#<Selenium::WebDriver::Element:0xa6219008 id="a2a2c83a-e52d-4464-81ec-4fce07ccc0b6">, #<Selenium::We...64378279">, #<Selenium::WebDriver::Element:0x..f90cc8d0e id="de990e21-eecf-48db-873b-76515dba7c3e">]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…