Как проверить значение выпадающего меню? - PullRequest
0 голосов
/ 08 ноября 2018

Я пытаюсь прочитать (используя транспортир и BDD) значения по умолчанию некоторых выпадающих списков. Для этого я пробовал несколько строк кода, но ни одна из них не работает.

Вот код, который я использую, console.log по какой-то причине не выполняется. Почему?

checkDropdownAssignment: function(dropdown,defaultValue) //Function to check the value assigned to a dropdown
{
    let texto=[];

    $$('* option:checked').each(function(element, index) { // Execute this operation for each element of the website
        element.getText().then(function (text) { //Get text of the element in order to compare it with the endpoint afterwards.
        texto.push(index.toString()); // Add one more component to the vector
        texto[index]=text; // Save the text in a variable visible outside of this function.
        console.log(texto[index]);
        });
    });
},

Заранее спасибо.

1 Ответ

0 голосов
/ 09 ноября 2018

Попробуйте:

$$('*option:checked').all(by.tagName('option')).getAttribute('label').then(function(value){
 for (var i=0; i<value.length; i++){
  expect(value).toContain(arayOfExpectedResults[i]);
 }
});

Здесь вы получаете массив со всеми метками внутри выпадающего списка и сравниваете их с ожидаемым результатом, или используете массив так, как хотите.

...