水豚随机抛出验证错误

问题描述 投票:0回答:1

在我的项目中,我有很多常见的表单(50),它们在表单之间存在着不同的领域。我的任务是遍历所有表单,填写所有必填字段并提交。但是我遇到了一个问题-按下提交按钮后,水豚在随机表单上抛出了一个错误,该错误显示:

Latitude couldn't be determined, maybe patient's or practice's postcodes are invalid?

完整的错误消息在这里:

1) Submit all non-interactive forms Submit all forms
     Failure/Error: expect(page).to have_content('Your form has been successfully submitted.')
       expected to find text "Your form has been successfully submitted." in "You are signed in as 'test_postcode (Test Practice) - [email protected]' | Sign out Settings View system messages Validation failed: Latitude couldn't be determined, maybe patient's or practice's postcodes are invalid? ← Back To Dashboard Referral An asterisk (*) indicates that a field is mandatory and a referral cannot be submitted without completing. STEP 1: ESSEX ORAL SURGERY TEST FORM * ROUTINE EXTRACTIONS ONLY ACCEPTED WHEN DETAILED JUSTIFICATION IS PROVIDED FOR WHY THIS CANNOT BE DONE IN PRIMARY CARE **PLEASE NOTE THAT THIS FORM SHOULD NOT BE USED FOR SUSPECTED CANCER REFERRALS. NOTE THAT INDICATING SEDATION / GA DOES NOT GUARANTEE PROVISION GENERAL ANAESTHETICS ARE NOT AVAILABLE FOR HEALTHY ADULTS UNDERGOING ROUTINE PROCEDURES. NHS number if known: Sex: M F Title: Mr Mrs Miss Ms Master Dr Patient’s first name: Patient’s last name: Date of birth: Patient's postcode: Patient's address: Patient's town or city: Best contact number: Is the patient exempt? Yes No Referrer’s name: Practice name: Date of decision to refer: Interpreter required Choose language Practice postcode: Practice address: Practice town or city: Practice phone number: GDC number: Care type: Routine Urgent Advice GMP's name: GMP's postcode: GMP's address: GMP's city or town: Patient is not registered with a doctor RADIOGRAPHS MUST BE ATTACHED FOR ALL EXTRACTIONS - PLEASE SUPPLY PA'S OF THIRD MOLARS IF NO ACCESS TO DPT Patient’s principal complaint: Everything You Need to Know About Dental and Oral Health Main reason for referral: Routine extraction of teeth* Removal of simple impacted teeth Surgical endodontics on single rooted anterior teeth Removal of buried / fractured root fragments Difficult extraction Complex impaction Other (e.g. benign oral mucosal lesions such as mucocoele/fibroepithelial polyp or facial pain/TMJ) Please indicate requested anaesthesia (please complete IOSN form if anything other than local) Local anaesthetic only IV Sedation GA If other describe here or use to provide more information: Referral Reason Text For extractions, please indicate below the teeth / roots to be removed: PERMANENT DENTITION 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 PRIMARY DENTITION e d c b a a b c d e e d c b a a b c d e Please describe why specialist care is required? Please describe any previous treatment for the condition referred. For third molars please explain how NICE guidelines are met? Reason for Care Does this patient require bariatric chair provision? Yes No Does this patient’s BMI suggest that they may not be able to receive sedation in primary care? Yes No Next step STEP 2: ADULT MEDICAL HISTORY STEP 3: UPLOAD FILES"

我查看了我的代码,并且知道我具有邮政编码验证:

validates_presence_of :latitude, :message => "couldn't be determined, maybe postcode is invalid?", if: :geocoding_expected?

def geocoding_expected?
  postcode.present?
end

def geocode
    coordinates = Routing::Geo::Utils.geocode(postcode, geocoding_address)
    self.latitude = coordinates['latitude']
    self.longitude = coordinates['longitude']
  end

这是功能规格代码,我在其中填写邮政编码字段:

if page.has_field?('patient_postcode', wait: 0)
      fill_in 'patient_postcode', with: 'BN20 8HR'
end

if page.has_field?('nursery_postcode', wait: 0)
  fill_in 'nursery_postcode', with: 'BN20 8HR'
end

但是在我所有的表格中,我都需要输入邮政编码-字段,我从以下英国站点填写此字段值:https://www.doogal.co.uk/PostcodeGenerator.php,我不知道为什么Capybara会抛出该验证错误。请帮助我!!

ruby-on-rails capybara
1个回答
0
投票

您的测试失败,因为该页面未包含您要告诉其的预期文本。问题是为什么文本不匹配。从错误中您可以看到问题出在您的模型在应用程序中的验证失败。要弄清楚为什么会发生这种情况,请查看您的test.log并查看实际发布到应用程序中的内容。有两种可能性

  1. 正在提交部分邮政编码-在这种情况下,通过在填写邮政编码后添加短暂的睡眠来进行诊断,如果可以解决此问题,则会告诉您,附加在邮政编码输入上的JS行为所需的处理时间比时间长它需要水豚去单击提交按钮。您可以不眠不休地解决问题,但是正确的解决方案是对页面上的任何vchange添加期望,以显示附加到输入的JS行为已完成。

  2. 完整的邮政编码正在提交-然后您的应用程序中有错误,或者您要填充的邮政编码被盗。

© www.soinside.com 2019 - 2024. All rights reserved.