classPersonalSection < SitePrism::Section
element :myservice, "#personal-my-services"
element :title, "#personal\\.title"
element :first, "#personal\\.firstName"
element :last, "#personal\\.lastName"
element :dob_day, "#personal\\.dobDay"
element :dob_month, "#personal\\.dobMonth"
element :dob_year, "#personal\\.dobYear"
element :summary, ".tms-accordion-summary-content"
element :next, ".tms-btn-next"end
最直接的使用方法就是直接调用set方法:
1 2 3 4 5 6 7 8 9 10 11 12
def fulfill_personal
@moving.personal.myservice.set"MINE"@moving.personal.title.select "Mr"@moving.personal.first.set"Juntao"@moving.personal.last.set"Qiu"@moving.personal.dob_day.select "21"@moving.personal.dob_month.select "Jan"@moving.personal.dob_year.select "1985"@moving.personal.next.click
end
这样在Cucumber测试中就可以写成:
1 2 3 4 5 6 7 8
Given /I am on moving home page/ do
@moving = MovingHome.new
@moving.load
endWhen /I fulfill my personal information/ do
fulfill_personal
end
Feature: Platinum Move
Scenario: Platinum Move
Given I am on moving home page
When I selectto move my service "Foxtel from Telstra"And I select a "Telstra technician install"Then I can see the lightbox "View Fees" shows up
Given /I am on moving home page/ do
@moving = MovingHome.new
@moving.load
end
When /I select to move my telstra service "([^"]*)"/ do |selected|
setup_data
@moving.service.fulfill selected
end
Then /I can see the installation form/ do
expect(@moving).to have_move_service
end
Then /I cannot see the installation form/ do
@moving.move_service.should_not be_visible
end
And /I select a "([^"]*)"/ do |install|
@moving.move_service.select_install install
end
Then /I can see the lightbox "([^"]*)" shows up/ do |name|
@moving.lightbox(name).should be_visible
end
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步