我需要通过yml文件迭代数据,直到哈希数据中的最后一个数据。 例如:下面我有一个yml文件,其中有name,city&校验。在这里,我需要逐个点击添加按钮添加这些细节,最后提交详细信息。任何身体都可以建议我..
samplepage:
name: ~sequential ['first', 'second', 'third']
city: ~sequential ['Ohmaha', 'New York', 'Coloumbia']
check: ~sequential ['yes', 'no', 'yes']
class SamplePage
include PageObject
include DataMagic
text_field(:sample_name, id: "name_value")
text_field(:sample_city, name: "city")
text_field(:sample_verify, name: "verify_status")
button(:add, text: "Add")
button(:submit, text: "Submit")
def enter_data
# here i need to iterate three values and add one by one
self.sample_name = name # related data
self.sample_city = city # related data
self.check = check # related data
add # added it
# at the last (after 3 values added to grid I should click submit button)
submit
end
end
答案 0 :(得分:1)
要一次迭代几个数组,您可以使用zip:
def enter_data(doc)
names, cities, checks = doc['samplepage'].values
names.zip(cities, checks).each do |name, city, check|
self.sample_name = name # related data
self.sample_city = city # related data
self.check = check # related data
add # added it
end
submit
end