acs::test::xpath::get_form_values (public)

 acs::test::xpath::get_form_values node xpath

Defined in packages/acs-automated-testing/tcl/aa-test-procs.tcl

Obtain form values (input fields and textareas) in form of a dict (attribute value pairs). The provided XPath expression must point to the HTML form containing the values to be extracted.

Parameters:
node (required)
xpath (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_folder_with_page create_folder_with_page (test xowf) acs::test::xpath::get_form_values acs::test::xpath::get_form_values test_create_folder_with_page->acs::test::xpath::get_form_values test_create_form_with_form_instance create_form_with_form_instance (test xowiki) test_create_form_with_form_instance->acs::test::xpath::get_form_values acs::test::xpath::get_name_attribute acs::test::xpath::get_name_attribute (private) acs::test::xpath::get_form_values->acs::test::xpath::get_name_attribute acs::test::xpath::get_form acs::test::xpath::get_form (public) acs::test::xpath::get_form->acs::test::xpath::get_form_values xowiki::test::get_form_values xowiki::test::get_form_values (private) xowiki::test::get_form_values->acs::test::xpath::get_form_values

Testcases:
create_folder_with_page, create_form_with_form_instance
Source code:
        set values {}
        foreach n [$node selectNodes $xpath//input] {
            set name [get_name_attribute $n $xpath//input]
            if {$name eq ""} continue

            # Disabled attributes are not sent together with the form
            # on submit, so we do not fetch them.
            if {[$n hasAttribute disabled]} {
                continue
            }

            # Do not consider unchecked radio buttons or checkboxes as
            # values
            if {[$n getAttribute type ""] in {"radio" "checkbox"} &&
                ![$n hasAttribute checked]} {
                continue
            }

            #ns_log notice "aa_xpath::get_form_values from $className input node $n name $name:"
            if {[$n hasAttribute value]} {
                set value [$n getAttribute value]
            } else {
                set value ""
            }
            lappend values $name $value
        }
        foreach n [$node selectNodes $xpath//textarea] {
            set name [get_name_attribute $n $xpath//textarea]
            if {$name eq ""} continue

            # Disabled attributes are not sent together with the form
            # on submit, so we do not fetch them.
            if {[$n hasAttribute disabled]} {
                continue
            }

            #ns_log notice "aa_xpath::get_form_values from $className textarea node $n name $name:"
            set value [$n text]
            lappend values $name $value
        }
        foreach n [$node selectNodes $xpath//select/option\[@selected='selected'\]] {
            set name [get_name_attribute [$n parentNode] $xpath//option/..]
            if {$name eq ""} continue

            # Disabled attributes are not sent together with the form
            # on submit, so we do not fetch them.
            if {[$n hasAttribute disabled]} {
                continue
            }

            set value [$n getAttribute value]
            lappend values $name $value
        }

        return $values
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: