1

When trying to write a simple Acceptance Test only creating a new Joomla Article Blog Menu Item, I'm doing this:

$I->createMenuItem('Blog', 'Articles', 'Category Blog', 'Main Menu');

I get this:

Step  I create menu item "Blog","Articles","Category Blog","Main Menu"
Fail  CSS or XPath element with link 'Select' was not found.

Everything runs as a Github Workflow and all other testing parts are working.

So what fails inside the JoomlaBrowser createMenuItem function is:

$this->click(array('link' => "Select"));

This is the reduced Report:

enter image description here

It's default Joomla menu item selection and "createMenuItem" is a default JoomlaBrowser Function. See here:

public function createMenuItem($menuTitle, $menuCategory, $menuItem, $menu = 'Main Menu', $language = 'All')
{
    $this->debug("I open the menus page");
    $this->amOnPage('administrator/index.php?option=com_menus&view=menus');
    $this->waitForText('Menus', TIMEOUT, array('css' => 'H1'));
    $this->checkForPhpNoticesOrWarnings();

    $this->debug("I click in the menu: $menu");
    $this->click(array('link' => $menu));
    $this->waitForText('Menus: Items', TIMEOUT, array('css' => 'H1'));
    $this->checkForPhpNoticesOrWarnings();

    $this->debug("I click new");
    $this->click("New");
    $this->waitForText('Menus: New Item', TIMEOUT, array('css' => 'h1'));
    $this->checkForPhpNoticesOrWarnings();
    $this->fillField(array('id' => 'jform_title'), $menuTitle);

    $this->debug("Open the menu types iframe");
    $this->click(array('link' => "Select"));
    $this->waitForElement(array('id' => 'menuTypeModal'), TIMEOUT);
    $this->wait(1);
    $this->switchToIFrame("Menu Item Type");

    $this->debug("Open the menu category: $menuCategory");

    // Open the category
    $this->wait(1);
    $this->waitForElement(array('link' => $menuCategory), TIMEOUT);
    $this->click(array('link' => $menuCategory));

    $this->debug("Choose the menu item type: $menuItem");
    $this->wait(1);
    $this->waitForElement(array('xpath' => "//a[contains(text()[normalize-space()], '$menuItem')]"), TIMEOUT);
    $this->click(array('xpath' => "//div[@id='collapseTypes']//a[contains(text()[normalize-space()], '$menuItem')]"));
    $this->debug('I switch back to the main window');
    $this->switchToIFrame();
    $this->debug('I leave time to the iframe to close');
    $this->wait(2);
    $this->selectOptionInChosen('Language', $language);
    $this->waitForText('Menus: New Item', '30', array('css' => 'h1'));
    $this->debug('I save the menu');
    $this->click("Save");

    $this->waitForText('Menu item saved', TIMEOUT, array('id' => 'system-message-container'));
}

Here is the composer packages i'm using:

{
    "name": "tests",
    "description": "Tests",
    "license": "GPL-2.0-or-later",
    "require": {},
    "require-dev": {
        "codeception/codeception": "^3",
        "joomla-projects/joomla-browser": "~v3",
        "joomla-projects/selenium-server-standalone": "~v3",
        "fzaninotto/faker": "^1.6",
        "behat/gherkin": "^4.4.1"
    }
}
4
  • This looks more like a bug and should be reported at github.com/joomla-projects/joomla-browser/issues the "Select" text is part of a span-tag and starts with a white-space, maybe that's the reason codeception can't the link to click.
    – Harald Leithner
    Jun 24 at 12:37
  • OK, i forked and cloned joomlabrowser and changed the Select line and when syncin my repos now it works. will try to change it to a more robust xpath selection.
    – Mike
    Jun 24 at 14:53
  • if you have a better one please submit it to the joomlabrowser repository.
    – Harald Leithner
    Jun 24 at 18:14
  • Colleague of mine wanted to do a pull request but some cs test are failing that have nothing to do with the changed line. Should be no problem to fix.
    – Mike
    Jun 24 at 18:48
1

This was actually a bug in the Joomla Browser and has been fixed now.

See https://github.com/joomla-projects/joomla-browser/pull/216

The current version should be able to create new menuitems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.