@@ -671,47 +671,59 @@ public function displayModuleOnAllPages($module)
671671 $ I ->waitForText ('Module successfully saved ' ,30 ,['id ' => 'system-message-container ' ]);
672672 }
673673
674- /**
675- * Creates a menu item with the Joomla menu manager, only working for menu items without additional required fields
676- *
677- * @param string $menuTitle The menu item title
678- * @param string $menuCategory The category of the menu type (for example Weblinks)
679- * @param string $menuItem The menu item type / link text (for example List all Web Link Categories)
680- * @param string $menu The menu where the item should be created
681- */
682- public function createMenuItem ($ menuTitle , $ menuCategory , $ menuItem , $ menu = "Main Menu " )
683- {
684- $ I = $ this ;
685- $ I ->amOnPage ('administrator/index.php?option=com_menus&view=menus ' );
686- $ I ->waitForText ('Menus ' , '30 ' , ['css ' => 'H1 ' ]);
687- $ this ->checkForPhpNoticesOrWarnings ();
674+ /**
675+ * Creates a menu item with the Joomla menu manager, only working for menu items without additional required fields
676+ *
677+ * @param string $menuTitle The menu item title
678+ * @param string $menuCategory The category of the menu type (for example Weblinks)
679+ * @param string $menuItem The menu item type / link text (for example List all Web Link Categories)
680+ * @param string $menu The menu where the item should be created
681+ * @param string $language If you are using Multilingual feature, the language for the menu
682+ */
683+ public function createMenuItem ($ menuTitle , $ menuCategory , $ menuItem , $ menu = 'Main Menu ' , $ language = 'All ' )
684+ {
685+ $ I = $ this ;
688686
689- // Choose the right menu
690- $ I ->click ([ ' xpath ' => " //*[@id= \" menuList \" ]/tbody/tr/td[2]/a[contains(text(), ' " . $ menu . " ')] " ]); ;
691- $ I ->waitForText ('Menus: Items ' , '30 ' , ['css ' => 'H1 ' ]);
687+ $ I -> debug ( " I open the menus page " );
688+ $ I ->amOnPage ( ' administrator/index.php?option=com_menus&view=menus ' ) ;
689+ $ I ->waitForText ('Menus ' , '60 ' , ['css ' => 'H1 ' ]);
692690 $ this ->checkForPhpNoticesOrWarnings ();
693691
694- $ I ->click ("New " );
695- $ I ->waitForText ('Menus: New Item ' , '30 ' , ['css ' => 'h1 ' ]);
692+ $ I ->debug ("I click in the menu: $ menu " );
693+ $ I ->click (['link ' => $ menu ]);
694+ $ I ->waitForText ('Menus: Items ' , '60 ' , ['css ' => 'H1 ' ]);
696695 $ this ->checkForPhpNoticesOrWarnings ();
697- $ I ->fillField (['id ' => 'jform_title ' ], $ menuTitle );
698-
699- // Menu type (modal)
700- $ I ->click (['xpath ' => "//a[@href= \"#menuTypeModal \"] " ]);
701- $ I ->waitForElement ('.iframe ' , '30 ' );
702- $ I ->switchToIFrame ("Menu Item Type " );
703-
704- // Open the category
705- $ I ->waitForElementVisible (['link ' => $ menuCategory ], '30 ' );
706- $ I ->click (['link ' => $ menuCategory ]);
707696
708- // Choose the menu item
709- $ I ->waitForElementVisible (['xpath ' => "//a[contains(text(), ' " . $ menuItem . "')] " ], 60 );
710- $ I ->click (['xpath ' => "//a[contains(text(), ' " . $ menuItem . "')] " ]);
711-
712- $ I ->waitForText ('Menus: New Item ' ,'30 ' , ['css ' => 'h1 ' ]);
697+ $ I ->debug ("I click new " );
698+ $ I ->click ("New " );
699+ $ I ->waitForText ('Menus: New Item ' , '60 ' , ['css ' => 'h1 ' ]);
700+ $ this ->checkForPhpNoticesOrWarnings ();
701+ $ I ->fillField (['id ' => 'jform_title ' ], $ menuTitle );
702+
703+ $ I ->debug ("Open the menu types iframe " );
704+ $ I ->click (['link ' => "Select " ]);
705+ $ I ->waitForElement (['id ' => 'menuTypeModal ' ], '60 ' );
706+ $ I ->switchToIFrame ("Menu Item Type " );
707+
708+ $ I ->debug ("Open the menu category: $ menuCategory " );
709+ // Open the category
710+ $ I ->wait (1 );
711+ $ I ->waitForElement (['link ' => $ menuCategory ], '60 ' );
712+ $ I ->click (['link ' => $ menuCategory ]);
713+
714+ $ I ->debug ("Choose the menu item type: $ menuItem " );
715+ $ I ->wait (1 );
716+ $ I ->waitForElement (['xpath ' => "//a[contains(text()[normalize-space()], ' $ menuItem')] " ], '60 ' );
717+ $ I ->click (['xpath ' => "//div[@id='collapseTypes']//a[contains(text()[normalize-space()], ' $ menuItem')] " ]);
718+ $ I ->debug ('I switch back to the main window ' );
719+ $ I ->switchToIFrame ();
720+ $ I ->debug ('I leave time to the iframe to close ' );
721+ $ I ->wait (2 );
722+ $ I ->selectOptionInChosen ('Language ' , $ language );
723+ $ I ->waitForText ('Menus: New Item ' ,'30 ' , ['css ' => 'h1 ' ]);
724+ $ I ->debug ('I save the menu ' );
713725 $ I ->click ("Save " );
714726
715- $ I ->waitForText ('Menu item successfully saved ' , 30 , ['id ' => 'system-message-container ' ]);
716- }
727+ $ I ->waitForText ('Menu item successfully saved ' , ' 60 ' , ['id ' => 'system-message-container ' ]);
728+ }
717729}
0 commit comments