Code Monkey home page Code Monkey logo

joomla-browser's Introduction

Joomla Browser (Codeception Module)

Latest Stable Version Total Downloads Latest Unstable Version License Build Status

Table of Contents

The Joomla Browser

Joomla Browser is a Codeception.com Module. It allows to build system tests for a Joomla site much faster providing a set of predefined tasks.

In between the available functions you can find:

  • INSTALLATION:
    • install joomla
    • install Joomla removing Installation Folder
    • install Joomla Multilingual Site
  • ADMINISTRATOR:
    • do administrator login
    • do administrator logout
    • set error reporting to development
    • search for item
    • check for item existence
    • publish a module
    • setting a module position and publishing it
    • EXTENSION MANAGER
      • install extension from Folder
      • install extension from url
      • enable plugin
      • uninstall extension
      • search result plugin name
  • FRONTEND:
    • do frontend login
  • ADMINISTRATOR USER INTERFACE:
    • select option in chosen
    • select Option In Radio Field
    • select Multiple Options In Chosen
  • OTHERS:
    • check for php notices or warnings

The Joomla Browser is constantly evolving and more methods are being added every month. To find a full list of them check the public methods at: https://github.com/joomla-projects/joomla-browser/blob/develop/src/JoomlaBrowser.php

Joomla Browser in action

If you want to see a working example of JoomlaBrowser check weblinks tests: https://github.com/joomla-extensions/weblinks#tests

Using Instructions

Update Composer.json file in your project, and download

Download

composer require joomla-projects/joomla-browser:dev-develop

Loading the Module in Codeception

Finally make the following changes in Acceptance.suite.yml to add JoomlaBrowser as a Module.

Your original acceptance.suite.ymlprobably looks like:

modules:
    enabled:
        - WebDriver
        - AcceptanceHelper
    config:
        WebDriver:
            url: 'http://localhost/joomla-cms3/'     # the url that points to the joomla cms
            browser: 'firefox'
            window_size: 1024x768
            capabilities:
              unexpectedAlertBehaviour: 'accept'
        AcceptanceHelper:
            ...

You should remove the WebDriver module and replace it with the JoomlaBrowser module:

    config:
        JoomlaBrowser:
            url: 'http://localhost/joomla-cms/'     # the url that points to the joomla installation at /tests/system/joomla-cms
            browser: 'firefox'
            window_size: 1024x768
            capabilities:
              unexpectedAlertBehaviour: 'accept'
            username: 'admin'
            password: 'admin'
            database host: 'localhost'             # place where the Application is Hosted #server Address
            database user: 'root'                  # MySQL Server user ID, usually root
            database password: '1234'                  # MySQL Server password, usually empty or root
            database name: 'dbname'            # DB Name, at the Server
            database type: 'mysqli'                # type in lowercase one of the options: MySQL\MySQLi\PDO
            database prefix: 'jos_'                # DB Prefix for tables
            install sample data: 'Yes'              # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
            sample data: 'Default English (GB) Sample Data'    # Default Sample Data
            admin email: '[email protected]'      # email Id of the Admin
            language: 'English (United Kingdom)'   # Language in which you want the Application to be Installed
            joomla folder: '/home/.../path to Joomla Folder' # Path to Joomla installation where we execute the tests
        AcceptanceHelper:
            ...

Code Style Checker

To check automatically the code style execute the following commands in your Terminal window at the root of the repository:

  • $ composer install
  • $ vendor/bin/phpcs --extensions=php -p --standard=vendor/joomla/coding-standards/Joomla src

joomla-browser's People

Contributors

810 avatar astridx avatar beat avatar brianteeman avatar compojoom avatar dependabot[bot] avatar dneukirchen avatar florianv avatar hackwar avatar isacandrei avatar jatitoam avatar javigomez avatar kubik-rubik avatar kylephp avatar laoneo avatar pritalpatel avatar puneet0191 avatar rdeutz avatar snipersister avatar svenbluege avatar vortrixs avatar wilsonge avatar wojsmol avatar yvesh avatar zero-24 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

joomla-browser's Issues

Create custom Locators

Hi, excuse my english.
I'm trying to create a custom locators inside \tests_support\Locators\mylocators.php.
In acceptance.suite.yml I added the parameter
locator class: 'Locators\mylocators'
mylocators.php code:

`<?php
namespace Codeception\Module\Locators;

class myLocators
{
}`
Running the test give the error:
Fatal error: Uncaught Error: Class 'Locators\mylocators' not found in C:\wamp64\www\jvams\vendor\joomla-projects\joomla-browser\src\JoomlaBrowser.php:100

Any idea? TIA

Add wait in clickInToolbarButton

@puneet0191 I was wondering if we should add a Wait in the Click toolbar Function:

https://github.com/joomla-projects/joomla-browser/blob/develop/src/JoomlaBrowser.php#L684

We used to do this:

        $I->waitForElement(['xpath' => "//button[contains(normalize-space(), 'New')]"], 60);
        $I->click(['xpath' => "//button[contains(normalize-space(), 'New')]"]);

And now, when using the clickToolbarFunction we are not waiting, having the risk of clicking the button when the page is not yet loaded. what do you think?

Drop use of jQuery, as it lead to failed test in Joomla 4

Drop use of jQuery, as it leads to failed test in Joomla 4

Example this section

public function selectOptionInChosenByIdUsingJs($selectId, $option)
{
$option = trim($option);
$this->executeJS("jQuery('#$selectId option').filter(function(){ return this.text.trim() === \"$option\" }).prop('selected', true);");
$this->executeJS("jQuery('#$selectId').trigger('liszt:updated').trigger('chosen:updated');");
$this->executeJS("jQuery('#$selectId').trigger('change');");
// Give time to Chosen to update
$this->wait(1);
}

Related discussion joomla/joomla-cms#32766
Example of failed test :
joomla/joomla-cms#32707
https://ci.joomla.org/joomla/joomla-cms/40772/1/22

New Release?

The current release is 4.0.0 and this doesnt include numerous changes and optimisations.

Joomla-cms is using 4.0.0 so its wasting time testing ftp etc

Will there be a new release?

Can't install joomla on windows

The system test fails to install joomla on my Windows machine. The test fails to find the next button on the page with the language select.

I see that in the test we have this

 // Select a random language to force reloading of the lang strings after selecting English
$I->selectOptionInChosen('#jform_language', 'Danish (DK)');
$I->selectOptionInChosen('#jform_language', 'English (United Kingdom)');

In my case I end up with danish, instead of english. Tried with waiting 2 sec between the selection, but this didn't help either. The only way to go around this is to just select english.

I'm also not sure that I understand the logic of the comment? Force reloading of the lang strings? The default language is english? Why do we need to reload it?

Error with UninstallExtension

Heya all folks!
Would like to report an issue with latest joomla-browser function uninstallExtension there.
More info can be found in log and uninstall file I provided:
uninstall.txt
ZZUninstallExtensionCept.txt

Error:

  1. ZZUninstallExtensionCept: Uninstall reditem extensions
    Test tests/acceptance/uninstall/ZZUninstallExtensionCept.php

[Facebook\WebDriver\Exception\UnknownServerException] Element is not clickable at point (429.76666259765625, 255). Other element would receive the click:


Command duration or timeout: 80 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'testing-gce-c74846d9-87db-49cc-a1e5-80c374d136ed', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-92-generic', java.version: '1.7.0_80'
Session ID: e2e1b980-839d-43c8-97cb-73ffe614ec69
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=38.4.0}]

Not J4 compatible

Is this still in use? Many of the functions (createMenuItem, selectOptionInRadioField, enablePlugin, selectOptionInChosenById) are not J4 compatible or obsolete.

Move wait(1) to a proper waitForElement in Joomla installation

@compojoom could you have a look at #93? is a hotfix, but if we remove it it fails. Ideally we should find somehow a exectueJS function to know when the Languages Chosen Selector is ready.

Because the problem is that if we don't wait by the time Selenium selects Danish as language...

screen shot 2016-01-15 at 13 39 48

... the javascript that refreshes the page with the loaded language is not ready. Therefore it never passes this line: https://github.com/joomla-projects/joomla-browser/blob/develop/src/JoomlaBrowser.php#L137

Do you think on a way we can get when this JS is loaded?

SelectOptionInChosen should search before selecting

This command: https://github.com/joomla-projects/joomla-browser/blob/develop/src/JoomlaBrowser.php#L423 clicks on the option in chosen. But what if the option that we want to click is not visible because is there many options with similar name:

screen shot 2015-11-10 at 12 19 29

To make sure SelectOptionInChosen do not fail with falsePositives we need to make it stronger by using the search field first and once the results are filtered then click:

screen shot 2015-11-10 at 12 22 01

See as example this code created not for Chosen but for Selectize.js https://gist.github.com/javigomez/33c03419b729674bdb77

Crating menu item (createMenuItem) is broken

unspecified

$I->switchToIFrame("Menu Item Type");

Seems not to work any longer. Exception: No frame element found by name or id Menu Item Type

Tested on Mac with current weblinks repository.

Improve xpaths in joomla installer to avoid selenium errors

Despite it works, selenium reports many errors due to Codeception heuristics trying to locate elements:

10:13:04.282 INFO - Done: [find elements: By.linkText: Install]
10:13:04.284 INFO - Executing: [click: 30 [[FirefoxDriver: firefox on MAC (29d41667-3048-714b-9f55-ea96aeee4067)] -> link text: Install]])
10:13:04.376 INFO - Done: [click: 30 [[FirefoxDriver: firefox on MAC (29d41667-3048-714b-9f55-ea96aeee4067)] -> link text: Install]]
10:13:04.379 INFO - Executing: [find element: By.xpath: //h3])
10:13:04.570 INFO - Done: [find element: By.xpath: //h3]
10:13:04.572 INFO - Executing: [get text: 27 [[FirefoxDriver: firefox on MAC (29d41667-3048-714b-9f55-ea96aeee4067)] -> xpath: //h3]])
10:13:05.132 WARN - Exception thrown
org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM
Command duration or timeout: 181 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
System info: host: 'JAVI.local', ip: '192.168.1.128', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.6.0_65'
Session ID: 29d41667-3048-714b-9f55-ea96aeee4067
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=41.0.1, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:269)
    at org.openqa.selenium.remote.RemoteWebElement.getText(RemoteWebElement.java:153)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement$1.invoke(EventFiringWebDriver.java:332)
    at com.sun.proxy.$Proxy2.getText(Unknown Source)
    at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.getText(EventFiringWebDriver.java:382)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.openqa.selenium.remote.server.KnownElements$1.invoke(KnownElements.java:64)
    at com.sun.proxy.$Proxy3.getText(Unknown Source)
    at org.openqa.selenium.remote.server.handler.GetElementText.call(GetElementText.java:30)
    at org.openqa.selenium.remote.server.handler.GetElementText.call(GetElementText.java:1)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
Caused by: org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
System info: host: 'JAVI.local', ip: '192.168.1.128', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.6.0_65'
Driver info: driver.version: unknown
    at <anonymous class>.fxdriver.cache.getElementAt(resource://fxdriver/modules/web-element-cache.js:8984)
    at <anonymous class>.Utils.getElementAt(file:///var/folders/41/bbd356hs31q2130rf9vylbq40000gn/T/anonymous7625181232791055018webdriver-profile/extensions/[email protected]/components/command-processor.js:8574)
    at <anonymous class>.WebElement.getElementText(file:///var/folders/41/bbd356hs31q2130rf9vylbq40000gn/T/anonymous7625181232791055018webdriver-profile/extensions/[email protected]/components/command-processor.js:11722)
    at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///var/folders/41/bbd356hs31q2130rf9vylbq40000gn/T/anonymous7625181232791055018webdriver-profile/extensions/[email protected]/components/command-processor.js:12282)
    at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///var/folders/41/bbd356hs31q2130rf9vylbq40000gn/T/anonymous7625181232791055018webdriver-profile/extensions/[email protected]/components/command-processor.js:12287)
    at <anonymous class>.DelayedCommand.prototype.execute/<(file:///var/folders/41/bbd356hs31q2130rf9vylbq40000gn/T/anonymous7625181232791055018webdriver-profile/extensions/[email protected]/components/command-processor.js:12229)
10:13:05.136 WARN - Exception: Element is no longer attached to the DOM
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
System info: host: 'JAVI.local', ip: '192.168.1.128', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.6.0_65'
Driver info: driver.version: unknown
10:13:05.403 INFO - Executing: [find element: By.xpath: //h3])
10:13:05.429 INFO - Done: [find element: By.xpath: //h3]
10:13:05.432 INFO - Executing: [get text: 31 [[FirefoxDriver: firefox on MAC (29d41667-3048-714b-9f55-ea96aeee4067)] -> xpath: //h3]])
10:13:05.464 INFO - Done: [get text: 31 [[FirefoxDriver: firefox on MAC (29d41667-3048-714b-9f55-ea96aeee4067)] -> xpath: //h3]]
10:13:05.717 INFO - Executing: [find element: By.xpath: //h3])

I'm sure we can improve the locators to avoid errors.

Toolbar commands fail at 480px resolution

At 480px resolution the toolbar buttons are hidden and only one "Toolbar" button is visibile. To see all buttons, you have to click on "Toolbar" first.

So, at this resolution, any step that requires a click on a toolbar button will fail.

Add support for different languages

This is really great component, big thanks!
But right now it only support English and I want to test my extension in different language(Russian).
There is no way I can do it. I can install and change default language, but after that nothing is working, because many methods rely on strings(in English, ofc), like 'Log out' or 'Log in'.
Maybe the best way to solve it - load Joomla Application into JoomlaBrowser class and use JText class inside. What do you think?

Improve CheckForNoticesAndWarnings

The function for CheckForNoticesAndWarnings is not very useful logging the errors, because it log errors like:

screen shot 2016-02-05 at 18 24 32

For this situations is convenient to dump the HTML source part affected. For example in my case was a false positive. If I would have seen...

screen shot 2016-02-05 at 18 26 28

... I would have been able to easily spot that the problem was the name of an INI string.

Instead we should change this function using maybe:

$I->_savePageSource(\Codeception\Configuration::outputDir() . '/pagesourceerror.log');

And then via php process the Source somehow and in case of error, respond with the specific part of the HTML source

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.