2016-10-19 6 views
1

私はCodepress doを使って、Wordpressアプリ内の高度なカスタムフィールドをテストします。動的IDと名前を持つselectOption

htmlの選択ボックスを見つけるのに問題があります。これは、静的な名前またはID(例:id="acf-field-field_58079c4650b04_type" name="fields[field_58079c4650b04])がないためです。数字は毎回変わります。

使用codeceptionsは

$I->selectOption("contains(@id, '_type')]", 'number'); 

私はそれはそれを見つけるために得ることができなかった、それは、このエラーがスローされます。

1) CreateNewFieldCest: Create a new advanced custom field 
Test tests/acceptance/CreateNewFieldCest.php:CreateNewField 
Step Select option "//input[@type='select' and contains(@id, '_type')]","number" 
Fail Field by name, label, CSS or XPath element with '//input[@type='select' and contains(@id, '_type')]' was not found. 

Scenario Steps: 

6. $I->selectOption("//input[@type='select' and contains(@id, '...","number") 
5. $I->wait(2) 
4. $I->fillField("//input[@type='text' and @class='label' a...","test field") 
3. $I->click("+ Add Field") 
2. $I->fillField("#title","test field") 
1. $I->amOnPage("/wp/wp-admin/post-new.php?post_type=acf") 


FAILURES! 
Tests: 1, Assertions: 0, Failures: 1. 
Script codecept handling the __exec_command event returned with error code 1 

誰もがダイナミックidと名前の選択ボックスを見つけるためにselectOptionを使用することができることへのアプローチをお勧めします。

答えて

0

Xパスは正しく表示されますが、DOMに含まれていれば見つかるはずです。

これはajaxリクエストから生成されますか?

おそらく、選択がレンダリングされていないか、またはまだ入力されていません。

あなたはそれが押されているボタンによってトリガーされますが、私はcodeceptionが失敗テストのスクリーンショットを生成して、それがレンダリングされていることがわかります

$I->waitForJs('return jQuery.active == 0', 10); 
+0

を完了するために、AJAXリクエストを待つために、このようなものを使用することができます表示されます:/ – DMH

関連する問題