From e92b61cb38b308f1451d274f5483c5c575c75b14 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 29 Jan 2024 10:47:57 +0300 Subject: Use XPath to specify form, and refine test Use XPath to pick the form by its ID rather than its numerical position which can change with the addition of (a) form(s) before the one we wish to test. --- test/requests/main_web_functionality.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'test/requests') diff --git a/test/requests/main_web_functionality.py b/test/requests/main_web_functionality.py index 40336f47..d4dae8b5 100644 --- a/test/requests/main_web_functionality.py +++ b/test/requests/main_web_functionality.py @@ -30,8 +30,13 @@ def check_search_page(host): def check_traits_page(host, traits_url): results = requests.get(host+traits_url) doc = document_fromstring(results.text) - traits_form = doc.forms[1] - assert(traits_form.fields["corr_dataset"] == "HC_M2_0606_P") + traits_forms = doc.xpath('//form[@id="trait_data_form"]') + + assert len(traits_forms) > 0, "Traits' form not found!" + assert len(traits_forms) == 1, "More than one form with the same ID" + traits_form2 = traits_forms[0] + + assert(traits_form2.fields["corr_dataset"] == "HC_M2_0606_P") print("OK") check_page(host, host+traits_url) -- cgit v1.2.3