Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 74... Línea 74...
74
                "//td[position()=2][contains(., //a[@title='User competency summary'][contains(., %locator%)])]",
74
                "//td[position()=2][contains(., //a[@title='User competency summary'][contains(., %locator%)])]",
75
            ]),
75
            ]),
76
        ];
76
        ];
77
    }
77
    }
Línea -... Línea 78...
-
 
78
 
-
 
79
    /**
-
 
80
     * Set the value of a competency filter.
-
 
81
     *
-
 
82
     * @When /^I set the competency filter "([^"]*)" to "([^"]*)"$/
-
 
83
     * @param string $fieldlocator The field locator.
-
 
84
     * @param string $value The value to set.
-
 
85
     * @throws Exception
-
 
86
     */
-
 
87
    public function set_competency_filter(
-
 
88
        string $fieldlocator,
-
 
89
        string $value,
-
 
90
    ): void {
-
 
91
        $field = behat_field_manager::get_form_field_from_label($fieldlocator, $this)->get_node();
-
 
92
        $session = $this->getSession();
-
 
93
 
-
 
94
        $value = trim($value);
-
 
95
 
-
 
96
        // Click into the field.
-
 
97
        $field->click();
-
 
98
 
-
 
99
        // Remove any existing text.
-
 
100
        do {
-
 
101
            behat_base::type_keys($session, [behat_keys::BACKSPACE, behat_keys::DELETE]);
-
 
102
        } while (strlen($field->getValue()) > 0);
-
 
103
        $this->wait_for_pending_js();
-
 
104
 
-
 
105
        // Type in the new value.
-
 
106
        behat_base::type_keys($session, str_split($value));
-
 
107
        $this->wait_for_pending_js();
-
 
108
 
-
 
109
        // If the autocomplete found suggestions, then it will have:
-
 
110
        // 1) marked itself as expanded; and
-
 
111
        // 2) have an aria-selected suggestion in the list.
-
 
112
        $expanded = $field->getAttribute('aria-expanded');
-
 
113
        $suggestion = $field->getParent()->getParent()->find('css', '.form-autocomplete-suggestions > [aria-selected="true"]');
-
 
114
 
-
 
115
        if ($expanded && null !== $suggestion) {
-
 
116
            // A suggestion was found.
-
 
117
            // Click on the first item in the list.
-
 
118
            $suggestion->click();
-
 
119
        } else {
-
 
120
            throw new \InvalidArgumentException(
-
 
121
                "Unable to find '{$value}' in the list of options."
-
 
122
            );
-
 
123
        }
-
 
124
 
-
 
125
        $this->wait_for_pending_js();
78
 
126
    }