D
D
Dobby Free2018-10-18 10:11:59
Yii
Dobby Free, 2018-10-18 10:11:59

How to view items in select?

There is a normal select on the form. I'm testing this form via codeception (functional tests).
There is such method $I->seeInFormFields. I will not understand in any way as to it to specify the list of options . Those. I know in advance what options should be there and I want to make sure that they are all there. For example if I write like this:

$I->seeInFormFields('form', ['Article[section_id]' => $sections]);

It gives me:
1) ArticleFormCest: Test add new article
 Test  tests\functional\ArticleFormCest.php:testAddNewArticle
 Step  See in form fields "form",{"Article[section_id]":["section1"]}
 Fail  Failed asserting that `section1` is in select's value: array (
  0 => '',
)
Failed asserting that an array contains 'section1'.

But I know for sure that this section is in the list of this select. It's just that nothing is selected by default.
upd. Debug I understood why this happens. I have two selects on a form that are connected to each other. Those. first the second select is empty and unselectable until you select one of the options in the first. After that, options are loaded in the second. I previously selected the option in the first one using the $I->selectOption method, but for some reason it didn’t get out like that, or it didn’t load in the second one, but the second one is empty ... I looked at the html through $I->grabPageSource() before calling $ I->seeInFormFields. I don't know what to do... Everything works correctly in the browser. Perhaps the tester selects the option somehow differently from the user. Without unnecessary clicks that javascript is guided to load in the second select option.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question