├── tests
├── _data
│ └── .gitkeep
├── _output
│ └── .gitignore
├── _support
│ ├── _generated
│ │ └── .gitignore
│ ├── Helper
│ │ └── Acceptance.php
│ └── AcceptanceTester.php
├── acceptance.suite.dist.yml
└── acceptance
│ └── JoomlaBrowserCest.php
├── codeception.yml
├── .gitignore
├── composer.json
├── src
├── ElementIsVisibleTrait.php
├── Locators
│ └── Locators.php
└── JoomlaBrowser.php
├── .drone.yml
├── README.md
└── LICENSE
/tests/_data/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/_output/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
--------------------------------------------------------------------------------
/tests/_support/_generated/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
--------------------------------------------------------------------------------
/tests/_support/Helper/Acceptance.php:
--------------------------------------------------------------------------------
1 | =7.2.0",
29 | "codeception/codeception": "~4.1",
30 | "codeception/module-webdriver": "^1.0",
31 | "codeception/module-phpbrowser": "^1.0.0",
32 | "codeception/module-asserts": "^1.0.0"
33 | },
34 | "require-dev": {
35 | "joomla/coding-standards": "~3.0@dev",
36 | "joomla/filesystem": "^2.0",
37 | "joomla/github": "^2.0",
38 | "squizlabs/php_codesniffer": "~3.0"
39 | },
40 | "autoload": {
41 | "psr-4": {
42 | "Joomla\\Browser\\": "src"
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/ElementIsVisibleTrait.php:
--------------------------------------------------------------------------------
1 | executeInSelenium(function (RemoteWebDriver $webDriver) use ($element, &$value)
37 | {
38 | try
39 | {
40 | $element = $webDriver->findElement(WebDriverBy::cssSelector($element));
41 | $value = $element instanceof RemoteWebElement;
42 | }
43 | catch (\Exception $e)
44 | {
45 | // Swallow exception silently
46 | }
47 | }
48 | );
49 | // phpcs:enable
50 |
51 | return $value;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/tests/acceptance.suite.dist.yml:
--------------------------------------------------------------------------------
1 | # Codeception Test Suite Configuration
2 | #
3 | # Suite for acceptance tests.
4 | # Perform tests in browser using the WebDriver or PhpBrowser.
5 | # If you need both WebDriver and PHPBrowser tests - create a separate suite.
6 |
7 | actor: AcceptanceTester
8 | modules:
9 | enabled:
10 | - Asserts
11 | - Joomla\Browser\JoomlaBrowser
12 | - Helper\Acceptance
13 | config:
14 | Joomla\Browser\JoomlaBrowser:
15 | url: 'http://localhost/test-install' # the url that points to the joomla installation at /tests/system/joomla-cms
16 | browser: 'chrome'
17 | window_size: 1920x1080
18 | capabilities:
19 | 'goog:chromeOptions':
20 | args: [ "headless", "whitelisted-ips", "disable-gpu", "no-sandbox", "window-size=1920x1080", "--disable-dev-shm-usage" ]
21 | name: 'jane doe' # Name for the Administrator
22 | username: 'ci-admin' # UserName for the Administrator
23 | password: 'joomla-17082005' # Password for the Administrator
24 | database host: 'mysql' # place where the Application is Hosted #server Address
25 | database user: 'root' # MySQL Server user ID, usually root
26 | database password: 'joomla_ut' # MySQL Server password, usually empty or root
27 | database name: 'test_joomla' # DB Name, at the Server
28 | database type: 'mysqli' # type in lowercase one of the options: MySQL\MySQLi\PDO
29 | database prefix: 'jos_' # DB Prefix for tables
30 | install sample data: 'no' # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
31 | sample data: 'Default English (GB) Sample Data' # Default Sample Data
32 | admin email: 'admin@example.org' # email Id of the Admin
33 | language: 'English (United Kingdom)' # Language in which you want the Application to be Installed
34 | timeout: 90 # or 90000 the same result
35 | log_js_errors: true
36 | cmsPath: '/tests/www/test-install' # ; If you want to setup your test website (document root) in a different folder, you can do that here.
37 | localUser: 'www-data' # (Linux / Mac only) If you want to set a different owner for the CMS test folder
38 | Helper\JoomlaDb:
39 | dsn: 'mysql:host=mysql;dbname=test_joomla'
40 | user: 'root'
41 | password: 'joomla_ut'
42 | prefix: 'jos_'
43 |
44 | error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED"
45 |
46 | step_decorators: ~
47 |
--------------------------------------------------------------------------------
/.drone.yml:
--------------------------------------------------------------------------------
1 | ---
2 | kind: pipeline
3 | name: default
4 |
5 | clone:
6 |
7 | steps:
8 | - name: composer
9 | image: joomlaprojects/docker-images:php7.4
10 | volumes:
11 | - name: composer-cache
12 | path: /tmp/composer-cache
13 | commands:
14 | - composer validate --no-check-all --strict
15 | - composer install --no-progress --no-suggest
16 |
17 | - name: phpcs
18 | image: joomlaprojects/docker-images:php7.4
19 | commands:
20 | - echo $(date)
21 | - ./vendor/bin/phpcs --extensions=php -p --standard=vendor/joomla/coding-standards/Joomla src
22 | - echo $(date)
23 |
24 | - name: prepare_test_environment
25 | image: joomlaprojects/docker-images:php7.4
26 | volumes:
27 | - name: composer-cache
28 | path: /tmp/composer-cache
29 | commands:
30 | - echo $(date)
31 | - mkdir cache
32 | - cd cache
33 | - git clone https://github.com/joomla/joomla-cms.git . --depth 1
34 | - composer install
35 |
36 | - name: npm
37 | image: node:16-bullseye-slim
38 | commands:
39 | - cd cache
40 | - npm i --unsafe-perm
41 |
42 | - name: acceptance_tests
43 | image: joomlaprojects/docker-images:systemtests
44 | environment:
45 | JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
46 | commands:
47 | - cp -a cache/. /tests/www/test-install/
48 | - chown -R www-data /tests/www/test-install/
49 | - apache2ctl -D FOREGROUND &
50 | - google-chrome --version
51 | - selenium-standalone start > tests/_output/selenium.log 2>&1 &
52 | - sleep 6
53 | - ./vendor/bin/codecept build
54 | - ./vendor/bin/codecept run --fail-fast --steps --debug tests/acceptance
55 |
56 | - name: artifacts-system-tests
57 | image: cschlosser/drone-ftps
58 | environment:
59 | FTP_USERNAME:
60 | from_secret: ftpusername
61 | FTP_PASSWORD:
62 | from_secret: ftppassword
63 | PLUGIN_HOSTNAME:
64 | from_secret: ftphost
65 | PLUGIN_SRC_DIR: /tests/_output/
66 | PLUGIN_DEST_DIR: /
67 | PLUGIN_SECURE: false
68 | PLUGIN_EXCLUDE: ^\.git/$
69 | commands:
70 | - export PLUGIN_DEST_DIR=$PLUGIN_DEST_DIR$DRONE_REPO/$DRONE_BRANCH/$DRONE_PULL_REQUEST/$DRONE_BUILD_NUMBER
71 | - echo https://artifacts.joomla.org/drone$PLUGIN_DEST_DIR
72 | - /bin/upload.sh
73 | when:
74 | status:
75 | - failure
76 |
77 | volumes:
78 | - name: composer-cache
79 | host:
80 | path: /tmp/composer-cache
81 |
82 | services:
83 | - name: mysql
84 | image: mysql:5.7
85 | environment:
86 | MYSQL_USER: joomla_ut
87 | MYSQL_PASSWORD: joomla_ut
88 | MYSQL_ROOT_PASSWORD: joomla_ut
89 | MYSQL_DATABASE: test_joomla
90 |
91 | ---
92 | kind: signature
93 | hmac: 1ea2fc9d8a1f85e589084eff1bdfe109f5d6df965db959f4e3e099344c9a4cf4
94 |
95 | ...
96 |
--------------------------------------------------------------------------------
/tests/acceptance/JoomlaBrowserCest.php:
--------------------------------------------------------------------------------
1 |
7 | * @license GNU General Public License version 2 or later; see LICENSE.txt
8 | */
9 |
10 | /**
11 | * Execute all features of JoomlaBrowser once
12 | *
13 | * @since 4.0
14 | */
15 | class JoomlaBrowserCest
16 | {
17 | public function testInstallations(AcceptanceTester $I)
18 | {
19 | $path = $I->getConfig('cmsPath');
20 | $I->wantToTest('installing Joomla');
21 | $I->installJoomla();
22 |
23 | /**
24 | * @TODO deleting install folder doesn't work
25 | * before Joomla 4.2. This return needs
26 | * to be removed when 4.2 is the default branch.
27 | */
28 | \Joomla\Filesystem\Folder::delete($path . '/installation');
29 |
30 | return;
31 |
32 | // Resetting installation to be installed again.
33 | if (is_file($path . '/configuration.php'))
34 | {
35 | unlink($path . '/configuration.php');
36 | }
37 |
38 | $I->wantToTest('installing Joomla and removing the install folder');
39 | $I->installJoomlaRemovingInstallationFolder();
40 |
41 | if (is_dir($path . '/installation'))
42 | {
43 | $I->fail('Installation folder wasn\'t deleted');
44 | }
45 |
46 | // Restoring installation folder to be installed again.
47 | if (is_file($path . '/configuration.php'))
48 | {
49 | unlink($path . '/configuration.php');
50 | }
51 |
52 | \Joomla\Filesystem\Folder::copy(
53 | __DIR__ . '/../../cache/installation',
54 | $path . '/installation'
55 | );
56 |
57 | $I->wantToTest('installing Joomla with multiple languages.');
58 | $I->installJoomlaMultilingualSite(['German', 'Chinese, Simplified', 'French']);
59 | }
60 |
61 | public function testSupportMethods(AcceptanceTester $I)
62 | {
63 | $I->doAdministratorLogin();
64 | $I->disableStatistics();
65 | $I->setErrorReportingToDevelopment();
66 | $I->setSiteSearchEngineFriendly();
67 | $I->setSiteOffline();
68 | $I->setSiteOffline(false);
69 | $I->checkForPhpNoticesOrWarnings();
70 | $I->amOnPage('/administrator/index.php?option=com_config');
71 | $I->verifyAvailableTabs(
72 | ['Site', 'System', 'Server', 'Logging', 'Text Filters', 'Permissions'],
73 | "//joomla-tab[@id='configTabs']/div[@role='tablist']/button"
74 | );
75 | //$I->clickToolbarButton($button, $subselector = null);
76 | }
77 |
78 | public function testUserManagement(AcceptanceTester $I)
79 | {
80 | $I->doAdministratorLogin();
81 | $I->createUser('Test User', 'testuser', 'Password123!', 'user@example.org', ['Registered']);
82 | $I->amOnPage('administrator/index.php');
83 | $I->doAdministratorLogout();
84 | $I->doFrontEndLogin('testuser', 'Password123!');
85 | $I->doFrontendLogout();
86 | }
87 |
88 | public function testExtensionManagement(AcceptanceTester $I)
89 | {
90 | // Get latest weblinks release, so that we have something to install
91 | $github = new \Joomla\Github\Github();
92 | $release = $github->repositories->releases->get('joomla-extensions', 'weblinks', 'latest');
93 | $url = $release->assets[0]->browser_download_url;
94 | $path = $I->getConfig('cmsPath');
95 |
96 | if (!is_file($path . '/weblinks.zip'))
97 | {
98 | file_put_contents(
99 | $path . '/weblinks.zip',
100 | file_get_contents($url)
101 | );
102 | copy($path . '/weblinks.zip', __DIR__ . '/../_data/weblinks.zip');
103 | }
104 |
105 | $I->doAdministratorLogin(null, null, false);
106 | $zip = new ZipArchive;
107 | $res = $zip->open($path . '/weblinks.zip');
108 |
109 | if ($res === true)
110 | {
111 | $zip->extractTo($path . '/tmp');
112 | $zip->close();
113 | }
114 | else
115 | {
116 | $I->fail('Can\'t extract weblinks package to folder');
117 | }
118 |
119 | $I->installExtensionFromFolder($path . '/tmp', 'pkg_weblinks');
120 | $I->uninstallExtension('Web Links Extension Package');
121 | $I->installExtensionFromUrl($url, 'pkg_weblinks');
122 | $I->uninstallExtension('Web Links Extension Package');
123 | $I->installExtensionFromFileUpload('weblinks.zip', 'pkg_weblinks');
124 |
125 | // $I->doAdministratorLogin(null, null, false);
126 | $I->installLanguage('Czech');
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Joomla Browser (Codeception Module)
2 | [](https://packagist.org/packages/joomla-projects/joomla-browser) [](https://packagist.org/packages/joomla-projects/joomla-browser) [](https://packagist.org/packages/joomla-projects/joomla-browser) [](https://packagist.org/packages/joomla-projects/joomla-browser) [](https://ci.joomla.org/joomla-projects/joomla-browser)
3 |
4 | ## Table of Contents
5 |
6 | * [The JoomlaBrowser](#the-joomla-browser)
7 | * [Using the JoomlaBrowser to test Joomla Sites](#using-instructions)
8 | * [Download](#download)
9 | * [Loading the Module in Codeception](loading-the-module-in-codeception)
10 |
11 | ## The Joomla Browser
12 | 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.
13 |
14 | In between the available functions you can find:
15 |
16 | * INSTALLATION:
17 | * install joomla
18 | * install Joomla removing Installation Folder
19 | * install Joomla Multilingual Site
20 | * ADMINISTRATOR:
21 | * do administrator login
22 | * do administrator logout
23 | * set error reporting to development
24 | * search for item
25 | * check for item existence
26 | * publish a module
27 | * setting a module position and publishing it
28 | * EXTENSION MANAGER
29 | * install extension from Folder
30 | * install extension from url
31 | * enable plugin
32 | * uninstall extension
33 | * search result plugin name
34 | * FRONTEND:
35 | * do frontend login
36 | * ADMINISTRATOR USER INTERFACE:
37 | * select option in chosen
38 | * select Option In Radio Field
39 | * select Multiple Options In Chosen
40 | * OTHERS:
41 | * check for php notices or warnings
42 |
43 |
44 | The Joomla Browser is constantly evolving and more methods are being added every month.
45 | To find a full list of them check the public methods at: https://github.com/joomla-projects/joomla-browser/blob/develop/src/JoomlaBrowser.php
46 |
47 |
48 | ## Joomla Browser in action
49 | If you want to see a working example of JoomlaBrowser check weblinks tests: https://github.com/joomla-extensions/weblinks#tests
50 |
51 | ## Using Instructions
52 | Update Composer.json file in your project, and download
53 |
54 | ### Download
55 |
56 | ```
57 | composer require joomla-projects/joomla-browser:dev-develop
58 | ```
59 |
60 | ### Loading the Module in Codeception
61 |
62 | Finally make the following changes in Acceptance.suite.yml to add JoomlaBrowser as a Module.
63 |
64 | Your original `acceptance.suite.yml`probably looks like:
65 |
66 | ```yaml
67 | modules:
68 | enabled:
69 | - WebDriver
70 | - AcceptanceHelper
71 | config:
72 | WebDriver:
73 | url: 'http://localhost/joomla-cms3/' # the url that points to the joomla cms
74 | browser: 'firefox'
75 | window_size: 1024x768
76 | capabilities:
77 | unexpectedAlertBehaviour: 'accept'
78 | AcceptanceHelper:
79 | ...
80 | ```
81 |
82 | You should remove the WebDriver module and replace it with the JoomlaBrowser module:
83 |
84 | ```yaml
85 | config:
86 | JoomlaBrowser:
87 | url: 'http://localhost/joomla-cms/' # the url that points to the joomla installation at /tests/system/joomla-cms
88 | browser: 'firefox'
89 | window_size: 1024x768
90 | capabilities:
91 | unexpectedAlertBehaviour: 'accept'
92 | username: 'admin'
93 | password: 'admin'
94 | database host: 'localhost' # place where the Application is Hosted #server Address
95 | database user: 'root' # MySQL Server user ID, usually root
96 | database password: '1234' # MySQL Server password, usually empty or root
97 | database name: 'dbname' # DB Name, at the Server
98 | database type: 'mysqli' # type in lowercase one of the options: MySQL\MySQLi\PDO
99 | database prefix: 'jos_' # DB Prefix for tables
100 | install sample data: 'Yes' # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
101 | sample data: 'Default English (GB) Sample Data' # Default Sample Data
102 | admin email: 'admin@mydomain.com' # email Id of the Admin
103 | language: 'English (United Kingdom)' # Language in which you want the Application to be Installed
104 | joomla folder: '/home/.../path to Joomla Folder' # Path to Joomla installation where we execute the tests
105 | AcceptanceHelper:
106 | ...
107 | ```
108 |
109 | ### Code Style Checker
110 | To check automatically the code style execute the following commands in your Terminal window at the root of the repository:
111 |
112 | - `$ composer install`
113 | - `$ vendor/bin/phpcs --extensions=php -p --standard=vendor/joomla/coding-standards/Joomla src`
114 |
--------------------------------------------------------------------------------
/src/Locators/Locators.php:
--------------------------------------------------------------------------------
1 | 'username'];
27 |
28 | /**
29 | * Locator for the Password field
30 | *
31 | * @var array
32 | * @since 3.7.4.2
33 | */
34 | public $loginPassword = ['id' => 'password'];
35 |
36 | /**
37 | * Locator for the Login Button
38 | *
39 | * @var array
40 | * @since 3.7.4.2
41 | */
42 | public $loginButton = ['xpath' => "//div[@class='com-users-login login']/form/fieldset/div[4]/div/button"];
43 |
44 | /**
45 | * Locator for the Logout Button
46 | *
47 | * @var array
48 | * @since 3.7.4.2
49 | */
50 | public $frontEndLoginSuccess = [
51 | 'xpath' => "//form[contains(@class, 'mod-login-logout')]/div[@class='mod-login-logout__button logout-button']"
52 | ];
53 |
54 | /**
55 | * Locator for the Logout Button
56 | *
57 | * @var array
58 | * @since 3.7.4.2
59 | */
60 | public $frontEndLogoutButton = [
61 | 'xpath' => "//div[contains(@class, 'logout-button')]//button[contains(text(), 'Log out')]"
62 | ];
63 |
64 | /**
65 | * Locator for the Login Button
66 | *
67 | * @var array
68 | * @since 3.7.4.2
69 | */
70 | public $frontEndLoginForm = ['xpath' => "//div[contains(@class, 'login')]//button[contains(text(), 'Log in')]"];
71 |
72 | /**
73 | * Locator for the Login Page Url
74 | *
75 | * @var array
76 | * @since 3.7.4.2
77 | */
78 | public $adminLoginPageUrl = '/administrator/index.php';
79 |
80 | /**
81 | * Locator for the administrator username field
82 | *
83 | * @var array
84 | * @since 3.7.4.2
85 | */
86 | public $adminLoginUserName = ['id' => 'mod-login-username'];
87 |
88 | /**
89 | * Locator for the admin password field
90 | *
91 | * @var array
92 | * @since 3.7.4.2
93 | */
94 | public $adminLoginPassword = ['id' => 'mod-login-password'];
95 |
96 | /**
97 | * Locator for the Login Button
98 | *
99 | * @var array
100 | * @since 3.7.4.2
101 | */
102 | public $adminLoginButton = ['xpath' => "//button[contains(normalize-space(), 'Log in')]"];
103 |
104 | /**
105 | * Locator for the Control Panel
106 | *
107 | * @var array
108 | * @since 3.7.4.2
109 | */
110 | public $controlPanelLocator = ['css' => 'h1.page-title'];
111 |
112 | /**
113 | * Locator for the Login URL
114 | *
115 | * @var array
116 | * @since 3.7.4.2
117 | */
118 | public $frontEndLoginUrl = '/index.php?option=com_users&view=login';
119 |
120 | /**
121 | * New Button in the Admin toolbar
122 | *
123 | * @var array
124 | * @since 3.7.5
125 | */
126 | public $adminToolbarButtonNew = ['class' => 'button-new'];
127 |
128 | /**
129 | * Apply Button in the Admin toolbar
130 | *
131 | * @var array
132 | * @since 3.7.5
133 | */
134 | public $adminToolbarButtonApply = ['class' => 'button-apply'];
135 |
136 | /**
137 | * Admin Control Panel Text
138 | *
139 | * @var array
140 | * @since 3.7.5
141 | */
142 | public $adminControlPanelText = 'Home Dashboard';
143 |
144 | /**
145 | * Admin Logout Dropdown
146 | *
147 | * @var array
148 | * @since 3.7.5
149 | */
150 | public $adminLogoutDropdown = ['css' => "button[title='User Menu']"];
151 |
152 | /**
153 | * Admin Login Text
154 | *
155 | * @var string
156 | * @since 3.7.5
157 | */
158 | public $adminLoginText = 'Log in';
159 |
160 | /**
161 | * Admin Logout Text
162 | *
163 | * @var array
164 | * @since 3.7.5
165 | */
166 | public $adminLogoutText = ['xpath' => "//a[text()[contains(.,'Log out')]]"];
167 |
168 | /**
169 | * Locator for the administrator login submit button
170 | *
171 | * @var array
172 | * @since 3.7.5
173 | */
174 | public $adminLoginSubmitButton = ['id' => 'btn-login-submit'];
175 |
176 | /**
177 | * Manage User - User Group Assignment Tab
178 | *
179 | * @var string
180 | * @since 3.9.1
181 | */
182 | public $adminManageUsersUserGroupAssignmentTab = 'Assigned User Groups';
183 |
184 | /**
185 | * Manage User - Account Details Tab
186 | *
187 | * @var string
188 | * @since 4.0.0
189 | */
190 | public $adminManageUsersAccountDetailsTab = 'Account Details';
191 |
192 | /**
193 | * Global Configuration - Site Tab
194 | *
195 | * @var string
196 | * @since 4.0.0
197 | */
198 | public $adminConfigurationSiteTab = array('xpath' => "//div[@role='tablist']/button[@aria-controls='page-site']");
199 |
200 | /**
201 | * Global Configuration - System Tab
202 | *
203 | * @var string
204 | * @since 4.0.0
205 | */
206 | public $adminConfigurationSystemTab = array('xpath' => "//div[@role='tablist']/button[@aria-controls='page-system']");
207 |
208 | /**
209 | * Global Configuration - Server Tab
210 | *
211 | * @var string
212 | * @since 4.0.0
213 | */
214 | public $adminConfigurationServerTab = array('xpath' => "//div[@role='tablist']/button[@aria-controls='page-server']");
215 |
216 | /**
217 | * Global Configuration URL
218 | *
219 | * @var string
220 | * @since 4.0.0
221 | */
222 | public static $globalConfigurationUrl = '/administrator/index.php?option=com_config';
223 |
224 | /**
225 | * Admin Module URL
226 | *
227 | * @var string
228 | * @since 4.0.0
229 | */
230 | public static $moduleUrl = '/administrator/index.php?option=com_modules';
231 |
232 | /**
233 | * Select Module Title
234 | *
235 | * @var string
236 | * @since 4.0.0
237 | */
238 | public static $moduleTitle = '#jform_title';
239 |
240 | /**
241 | * Select Filter Options
242 | *
243 | * @var array
244 | * @since 4.0.0
245 | */
246 | public static $filterOptions = ['link' => 'Filtering Options'];
247 |
248 | /**
249 | * Select Filter Options
250 | *
251 | * @var string
252 | * @since 4.0.0
253 | */
254 | public static $selectModuleCategory = '#jform_params_catid';
255 |
256 | /**
257 | * Fill Category
258 | *
259 | * @var string
260 | * @since 4.0.0
261 | */
262 | public static $fillModuleCategory = '//div[@id="jform_params_catid_chzn"]/ul/li/input';
263 |
264 | /**
265 | * Select Module category
266 | *
267 | * @var string
268 | * @since 4.0.0
269 | */
270 | public static $moduleCategory = 'jform_params_catid_chzn';
271 |
272 | /**
273 | * Manage User - User Group Assignment Tab - User Group checkbox
274 | *
275 | * @param string $userGroup display name of the user group
276 | *
277 | * @return array
278 | * @since 3.9.1
279 | */
280 | public function adminManageUsersUserGroupAssignmentCheckbox($userGroup)
281 | {
282 | return array('xpath' => "//label[contains(text()[normalize-space()], '$userGroup')]");
283 | }
284 | }
285 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------
/src/JoomlaBrowser.php:
--------------------------------------------------------------------------------
1 | instantiateLocator();
72 | }
73 |
74 | /**
75 | * Function to instantiate the Locator Class, In case of a custom Template,
76 | * path to the custom Template Locator could be passed in Acceptance.suite.yml file
77 | *
78 | * for example: If the Class is present at _support/Page/Acceptance folder, simple add a new Parameter in acceptance.suite.yml file
79 | *
80 | * locator class: 'Page\Acceptance\Bootstrap2TemplateLocators'
81 | *
82 | * Locator could be set to null like this
83 | *
84 | * locator class: null
85 | *
86 | * When set to null, Joomla Browser will use the custom Locators present inside Locators.php
87 | *
88 | * @return void
89 | *
90 | * @since 3.0.0
91 | */
92 | protected function instantiateLocator()
93 | {
94 | if (empty($this->config['locator class']))
95 | {
96 | $this->locator = new Locators;
97 |
98 | return;
99 | }
100 |
101 | $class = $this->config['locator class'];
102 | $this->locator = new $class;
103 | }
104 |
105 | /**
106 | * Function to Do Admin Login In Joomla!
107 | *
108 | * @param string|null $user Optional Username. If not passed the one in acceptance.suite.yml will be used
109 | * @param string|null $password Optional password. If not passed the one in acceptance.suite.yml will be used
110 | * @param bool $useSnapshot Whether or not you want to reuse the session from previous login. Enabled by default.
111 | *
112 | * @return void
113 | *
114 | * @since 3.0.0
115 | * @throws Exception
116 | */
117 | public function doAdministratorLogin($user = null, $password = null, $useSnapshot = true)
118 | {
119 | if (is_null($user))
120 | {
121 | $user = $this->config['username'];
122 | }
123 |
124 | if (is_null($password))
125 | {
126 | $password = $this->config['password'];
127 | }
128 |
129 | if ($useSnapshot && $this->loadSessionSnapshot($user))
130 | {
131 | return;
132 | }
133 |
134 | $this->debug('I open Joomla Administrator Login Page');
135 | $this->amOnPage($this->locator->adminLoginPageUrl);
136 | $this->waitForElement($this->locator->adminLoginUserName, $this->config['timeout']);
137 |
138 | // Wait for CSS animations to finish (1 second in scss - give 1.5 to be safe)
139 | $this->wait(1.5);
140 |
141 | $this->debug('Fill Username Text Field');
142 | $this->fillField($this->locator->adminLoginUserName, $user);
143 | $this->debug('Fill Password Text Field');
144 | $this->fillField($this->locator->adminLoginPassword, $password);
145 |
146 | // Wait for JS to execute
147 | $this->wait(1.5);
148 |
149 | // @todo: update login button in joomla login screen to make this xPath more friendly
150 | $this->debug('I click Login button');
151 | $this->click($this->locator->adminLoginButton);
152 | $this->debug('I wait to see Administrator Control Panel');
153 | $this->waitForText($this->locator->adminControlPanelText, $this->config['timeout'], $this->locator->controlPanelLocator);
154 |
155 | if ($useSnapshot)
156 | {
157 | $this->saveSessionSnapshot($user);
158 | }
159 | }
160 |
161 | /**
162 | * Function to Do Frontend Login In Joomla!
163 | *
164 | * @param string|null $user Optional username. If not passed the one in acceptance.suite.yml will be used
165 | * @param string|null $password Optional password. If not passed the one in acceptance.suite.yml will be used
166 | *
167 | * @return void
168 | *
169 | * @since 3.0.0
170 | * @throws Exception
171 | */
172 | public function doFrontEndLogin($user = null, $password = null)
173 | {
174 | if (is_null($user))
175 | {
176 | $user = $this->config['username'];
177 | }
178 |
179 | if (is_null($password))
180 | {
181 | $password = $this->config['password'];
182 | }
183 |
184 | $this->debug('I open Joomla Frontend Login Page');
185 | $this->amOnPage($this->locator->frontEndLoginUrl);
186 | $this->debug('Fill Username Text Field');
187 | $this->fillField($this->locator->loginUserName, $user);
188 | $this->debug('Fill Password Text Field');
189 | $this->fillField($this->locator->loginPassword, $password);
190 |
191 | // @todo: update login button in joomla login screen to make this xPath more friendly
192 | $this->debug('I click Login button');
193 | $this->click($this->locator->loginButton);
194 | $this->debug('I wait to see Frontend Member Profile Form with the Logout button in the module');
195 |
196 | $this->waitForElement($this->locator->frontEndLoginSuccess, $this->config['timeout']);
197 | }
198 |
199 | /**
200 | * Function to Do frontend Logout in Joomla!
201 | *
202 | * @return void
203 | *
204 | * @since 3.0.0
205 | * @throws Exception
206 | */
207 | public function doFrontendLogout()
208 | {
209 | $this->debug('I open Joomla Frontend Login Page');
210 | $this->amOnPage($this->locator->frontEndLoginUrl);
211 | $this->debug('I click Logout button');
212 | $this->click($this->locator->frontEndLogoutButton);
213 | $this->amOnPage('/index.php?option=com_users&view=login');
214 | $this->debug('I wait to see Login form');
215 | $this->waitForElement($this->locator->frontEndLoginForm, 30);
216 | $this->seeElement($this->locator->frontEndLoginForm);
217 | }
218 |
219 | /**
220 | * Installs Joomla
221 | *
222 | * @return void
223 | *
224 | * @since 4.0.0
225 | * @throws Exception
226 | */
227 | public function installJoomla()
228 | {
229 | $this->debug('I open Joomla Installation Configuration Page');
230 | $this->amOnPage('/installation/index.php');
231 |
232 | // I Wait for the text Main Configuration, meaning that the page is loaded
233 | $this->debug('I wait for Main Configuration');
234 | $this->waitForElement('#jform_language', 10);
235 | $this->debug('I select en-GB as installation language');
236 | $this->selectOption('#jform_language', 'English (United Kingdom)');
237 | $this->debug('Wait for the page to reload in the selected language');
238 | $this->wait(2);
239 |
240 | if ($this->grabTextFrom('#jform_language-lbl') != 'Select Language')
241 | {
242 | // Due to a bug, we first need to select a different language and then go back to english
243 | $this->selectOption('#jform_language', 'Deutsch (Deutschland)');
244 | $this->debug('Wait for the page to reload in the selected language');
245 | $this->wait(2);
246 | $this->selectOption('#jform_language', 'English (United Kingdom)');
247 | $this->debug('Wait for the page to reload in the selected language');
248 | $this->wait(2);
249 | }
250 |
251 | $this->debug('I fill Site Name');
252 | $this->fillField(['id' => 'jform_site_name'], 'Joomla CMS test');
253 | $this->click(['id' => 'step1']);
254 |
255 | // I get the configuration from acceptance.suite.yml (see: tests/_support/acceptancehelper.php)
256 | $this->debug('I fill Admin Email');
257 | $this->fillField(['id' => 'jform_admin_email'], $this->config['admin email']);
258 | $this->debug('I fill Admin Name');
259 | $this->fillField(['id' => 'jform_admin_user'], $this->config['name']);
260 | $this->debug('I fill Admin Username');
261 | $this->fillField(['id' => 'jform_admin_username'], $this->config['username']);
262 | $this->debug('I fill Admin Password');
263 | $this->fillField(['id' => 'jform_admin_password'], $this->config['password']);
264 | $this->click(['id' => "step2"]);
265 |
266 | $this->debug('I Fill the form for creating the Joomla site Database');
267 |
268 | $this->debug('I select ' . $this->config['database type']);
269 | $this->selectOption(['id' => 'jform_db_type'], $this->config['database type']);
270 | $this->debug('I fill Database Host');
271 | $this->fillField(['id' => 'jform_db_host'], $this->config['database host']);
272 | $this->debug('I fill Database User');
273 | $this->fillField(['id' => 'jform_db_user'], $this->config['database user']);
274 | $this->debug('I fill Database Password');
275 | $this->fillField(['id' => 'jform_db_pass'], $this->config['database password']);
276 | $this->debug('I fill Database Name');
277 | $this->fillField(['id' => 'jform_db_name'], $this->config['database name']);
278 | $this->debug('I fill Database Prefix');
279 | $this->fillField(['id' => 'jform_db_prefix'], $this->config['database prefix']);
280 | $this->debug('I click Install Joomla Button');
281 | $this->click(['id' => 'setupButton']);
282 | $this->waitForText('Congratulations! Your Joomla site is ready.', $this->config['timeout'], ['xpath' => '//h2']);
283 | }
284 |
285 | /**
286 | * Install Joomla removing the Installation folder at the end of the execution
287 | *
288 | * @return void
289 | *
290 | * @since 4.0.0
291 | */
292 | public function installJoomlaRemovingInstallationFolder()
293 | {
294 | $this->installJoomla();
295 |
296 | $this->removeInstallationFolder();
297 |
298 | $this->debug('Joomla is now installed');
299 | $this->click('Open Administrator');
300 | }
301 |
302 | /**
303 | * Installs Joomla with Multilingual Feature active
304 | *
305 | * @param array $languages Array containing the language names to be installed
306 | *
307 | * @return void
308 | *
309 | * @since 3.0.0
310 | * @throws Exception
311 | * @example : $this->installJoomlaMultilingualSite(['Spanish', 'French']);
312 | *
313 | */
314 | public function installJoomlaMultilingualSite($languages = array())
315 | {
316 | if (!$languages)
317 | {
318 | // If no language is passed French will be installed by default
319 | $languages[] = 'French';
320 | }
321 |
322 | $this->installJoomla();
323 |
324 | $this->debug('I go to Install Languages page');
325 | $this->click(['id' => 'installAddFeatures']);
326 | $this->waitForText('Install Additional Languages', $this->config['timeout']);
327 |
328 | foreach ($languages as $language)
329 | {
330 | $this->debug('I mark the checkbox of the language: ' . $language);
331 | $this->scrollTo(['xpath' => "//label[contains(text()[normalize-space()], '$language')]"]);
332 | $this->wait(.5);
333 | $this->click(['xpath' => "//label[contains(text()[normalize-space()], '$language')]"]);
334 | }
335 |
336 | $this->scrollTo(['id' => 'installLanguagesButton']);
337 | $this->wait(.5);
338 | $this->click(['id' => 'installLanguagesButton']);
339 | $this->waitForText('Set default language', $this->config['timeout'], ['id' => 'defaultLanguagesButton']);
340 | $this->seeOptionIsSelected('input[name=administratorlang]', 'English (en-GB)');
341 | $this->seeOptionIsSelected('input[name=frontendlang]', 'English (en-GB)');
342 | $this->scrollTo('#defaultLanguagesButton');
343 | $this->wait(.5);
344 | $this->click('#defaultLanguagesButton');
345 | $this->wait(1);
346 | $this->scrollTo(['id' => 'system-message-container']);
347 | $this->waitForText('Joomla has set en-GB as your default ADMINISTRATOR language.', $this->config['timeout']);
348 | $this->see('Joomla has set en-GB as your default ADMINISTRATOR language.');
349 |
350 | $this->removeInstallationFolder();
351 |
352 | $this->debug('Joomla is now installed');
353 | $this->scrollTo('#installCongrat');
354 | $this->wait(.5);
355 | $this->see('Open Site');
356 | }
357 |
358 | /**
359 | * Remove the installation folder after installing Joomla.
360 | *
361 | * @return void
362 | *
363 | * @since 4.0.0
364 | * @throws Exception
365 | *
366 | */
367 | protected function removeInstallationFolder()
368 | {
369 | if ($this->haveVisible('#removeInstallationFolder'))
370 | {
371 | $this->debug('Removing Installation Folder');
372 | $this->scrollTo(['id' => 'removeInstallationFolder']);
373 | $this->wait(1);
374 | $this->click(['id' => 'removeInstallationFolder']);
375 |
376 | // Accept the confirmation alert
377 | $this->seeInPopup('Are you sure you want to delete?');
378 | $this->acceptPopup();
379 |
380 | // Wait until the installation folder is gone and the "customize installation" box has been removed
381 | $this->waitForElementNotVisible(['id' => 'installAddFeatures'], 30);
382 | }
383 | }
384 |
385 | /**
386 | * Sets in Administrator->Global Configuration the Error reporting to Maximum (formerly development)
387 | * {@internal doAdminLogin() before}
388 | *
389 | * @return void
390 | *
391 | * @since 3.0.0
392 | * @throws Exception
393 | */
394 | public function setErrorReportingToDevelopment()
395 | {
396 | $this->debug('I open Joomla Global Configuration Page');
397 | $this->amOnPage('/administrator/index.php?option=com_config');
398 | $this->debug('I wait for Global Configuration title');
399 | $this->waitForText('Global Configuration', $this->config['timeout'], ['css' => '.page-title']);
400 | $this->debug('I open the Server Tab');
401 |
402 | // TODO improve
403 | $this->wait(1);
404 | $this->click($this->locator->adminConfigurationServerTab);
405 | $this->debug('I wait for error reporting dropdown');
406 | $this->selectOption('Error Reporting', 'Maximum');
407 | $this->debug('I click on save');
408 | $this->clickToolbarButton('save');
409 | $this->debug('I wait for global configuration being saved');
410 | $this->waitForText('Global Configuration', $this->config['timeout'], ['css' => '.page-title']);
411 | $this->waitForText('Configuration saved.', $this->config['timeout'], ['id' => 'system-message-container']);
412 | }
413 |
414 | /**
415 | * Installs a Extension in Joomla that is located in a folder inside the server
416 | *
417 | * @param String $path Path for the Extension
418 | * @param string $type Type of Extension
419 | *
420 | * {@internal doAdminLogin() before}
421 | *
422 | * @return void
423 | *
424 | * @since 3.0.0
425 | * @throws Exception
426 | */
427 | public function installExtensionFromFolder($path, $type = 'Extension')
428 | {
429 | $this->amOnPage('/administrator/index.php?option=com_installer');
430 | $this->waitForText('Extensions: Install', '30', ['css' => 'H1']);
431 | $this->click('Install from Folder');
432 | $this->debug('I enter the Path');
433 | $this->fillField(['id' => 'install_directory'], $path);
434 | $this->click(['id' => 'installbutton_directory']);
435 | $this->waitForText('was successful', $this->config['timeout'], ['id' => 'system-message-container']);
436 | $this->debug("$type successfully installed from $path");
437 | }
438 |
439 | /**
440 | * Installs a Extension in Joomla that is located in a url
441 | *
442 | * @param String $url Url address to the .zip file
443 | * @param string $type Type of Extension
444 | *
445 | * {@internal doAdminLogin() before}
446 | *
447 | * @return void
448 | *
449 | * @since 3.0.0
450 | * @throws Exception
451 | */
452 | public function installExtensionFromUrl($url, $type = 'Extension')
453 | {
454 | $this->amOnPage('/administrator/index.php?option=com_installer');
455 | $this->waitForText('Extensions: Install', '30', ['css' => 'H1']);
456 | $this->click('Install from URL');
457 | $this->debug('I enter the url');
458 | $this->fillField(['id' => 'install_url'], $url);
459 | $this->click(['id' => 'installbutton_url']);
460 | $this->waitForText('was successful', '30', ['id' => 'system-message-container']);
461 |
462 | $this->debug("$type successfully installed from $url");
463 | }
464 |
465 | /**
466 | * Installs a Extension in Joomla using the file upload option
467 | *
468 | * @param string $file Path to the file in the _data folder
469 | * @param string $type Type of Extension
470 | *
471 | * {@internal doAdminLogin() before}
472 | *
473 | * @return void
474 | * @throws Exception
475 | */
476 | public function installExtensionFromFileUpload($file, $type = 'Extension')
477 | {
478 | $this->amOnPage('/administrator/index.php?option=com_installer');
479 | $this->waitForText('Extensions: Install', '30', array('css' => 'H1'));
480 | $this->click('Upload Package File');
481 |
482 | $this->debug('I make sure legacy uploader is visible');
483 | $this->executeJS('document.getElementById("legacy-uploader").style.display="block";');
484 |
485 | $this->debug('I enter the file input');
486 | $this->attachFile(array('id' => 'install_package'), $file);
487 |
488 | $this->waitForText('was successful', '30', array('id' => 'system-message-container'));
489 |
490 | $this->debug("$type successfully installed with file upload");
491 | }
492 |
493 | /**
494 | * Function to check for PHP Notices or Warnings
495 | *
496 | * @param string $page Optional, if not given checks will be done in the current page
497 | *
498 | * {@internal doAdminLogin() before}
499 | *
500 | * @return void
501 | *
502 | * @since 3.0.0
503 | */
504 | public function checkForPhpNoticesOrWarnings($page = null)
505 | {
506 | if ($page)
507 | {
508 | $this->amOnPage($page);
509 | }
510 |
511 | $this->dontSeeInPageSource('Deprecated:');
512 | $this->dontSeeInPageSource('Deprecated:');
513 | $this->dontSeeInPageSource('Notice:');
514 | $this->dontSeeInPageSource('Notice:');
515 |
516 | // $this->dontSeeInPageSource('Warning:'); We have translation strings with this in the backend.
517 | $this->dontSeeInPageSource('Warning:');
518 | $this->dontSeeInPageSource('Strict standards:');
519 | $this->dontSeeInPageSource('Strict standards:');
520 | $this->dontSeeInPageSource('The requested page can\'t be found');
521 | }
522 |
523 | /**
524 | * Selects an option in a Joomla Radio Field based on its label
525 | *
526 | * @param string $label The text in the