[FIX] web_tour: tour_manager: choose option for select element

Before this commit, it was only possible to set an option with
his value.

For example:
<select name="test">
  <option value="1">One</option>
  <option value="2">Two</option>
</select>

The only way to set the first option was to do the following:
run: "text 1"

With this commit, we can now select the first option with his text value:
run "test One"

We need this because in 'main_flow_tour', some values are generated ids.
This commit is contained in:
Adrien Dieudonne
2017-07-27 13:58:51 +02:00
parent a71f223702
commit 17a9e45566
@@ -146,10 +146,13 @@ var RunningTourActionHelper = core.Class.extend({
if (values.consume_event === "input") {
values.$element.trigger("keydown").val(text).trigger("keyup").trigger("input");
} else if (values.$element.is("select")) {
values.$element.children("option")
.prop("selected", false).removeProp("selected")
.filter(function () { return $(this).val() === text; })
.prop("selected", true);
var $options = values.$element.children("option");
$options.prop("selected", false).removeProp("selected");
var $selectedOption = $options.filter(function () { return $(this).val() === text; });
if ($selectedOption.length === 0) {
$selectedOption = $options.filter(function () { return $(this).text() === text; });
}
$selectedOption.prop("selected", true);
this._click(values);
} else {
values.$element.text(text);