|
1 | 1 | # php-selenium-browserstack |
2 | | -Code samples for php selenium tests on browserstack. |
3 | | - |
4 | | -## Prerequisites |
5 | | -1. `php` and `composer` should be installed in your system. |
6 | | -* If you don't already use Composer, you can download the composer.phar binary: |
7 | | -``` |
8 | | -curl -sS https://getcomposer.org/installer | php |
9 | | -``` |
10 | | - |
11 | | -## Steps to run test sessions |
12 | | -1. Clone the repo |
13 | | -``` |
14 | | -git clone https://github.com/browserstack/php-selenium-browserstack.git |
15 | | -``` |
16 | | -2. Install dependencies |
17 | | -``` |
18 | | - php composer.phar install |
19 | | -``` |
20 | | -3. Set your credentials in the `config.php` file. Update `YOUR_USERNAME` and `YOUR_ACCESS_KEY` with your username and access key. |
21 | | -You can also set them as environment variables `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY`, as follows: |
22 | | - * For Unix-like or Mac machines: |
| 2 | + |
| 3 | +This branch contains php tests using [PHPUnit](https://github.com/sebastianbergmann/phpunit). |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. Make sure that you have **PHP** installed on your system. You can download and install **PHP** using following commands in the terminal: |
| 8 | + |
| 9 | + - **MacOS:** |
| 10 | + ```bash |
| 11 | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 12 | + brew install php |
| 13 | + ``` |
| 14 | + - **Windows:** |
| 15 | + ```bash |
| 16 | + sudo apt-get install curl libcurl3 libcurl3-dev php |
| 17 | + ``` |
| 18 | + **Note:** For **Windows**, you can download **PHP** from [here](http://windows.php.net/download/). Also, refer to this [documentation](http://php.net/manual/en/install.windows.php) for ensuring the accessibility of PHP through the Command Prompt. |
| 19 | + |
| 20 | +2. Download **composer** in the project directory ([Linux/MacOS](https://getcomposer.org/download/), [Windows](https://getcomposer.org/doc/00-intro.md#installation-windows)). |
| 21 | + |
| 22 | + **Note:** To use the **composer** command directly, it either should have been downloaded in the project directory or should be accessible globally which can be done by the command below: |
| 23 | + |
| 24 | + ```bash |
| 25 | + mv composer.phar /usr/local/bin/composer |
| 26 | + ``` |
| 27 | + |
| 28 | +## Setup |
| 29 | + |
| 30 | +- Clone the repo |
| 31 | +- Install dependencies using: `composer install` |
| 32 | +- Update `test.conf.json` file inside the `config/` directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings) |
| 33 | + |
| 34 | +## Running your tests |
| 35 | + |
| 36 | +- To run tests, run: `composer test` |
| 37 | +- To run local tests, run: `composer local` |
| 38 | + |
| 39 | +Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) |
| 40 | + |
| 41 | +## Notes |
| 42 | + |
| 43 | +- You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate) |
| 44 | +- To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/php#setting-os-and-browser) |
| 45 | +- You can export the environment variables for the Username and Access Key of your BrowserStack account |
| 46 | + |
23 | 47 | ``` |
24 | 48 | export BROWSERSTACK_USERNAME=<browserstack-username> && |
25 | 49 | export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key> |
26 | 50 | ``` |
27 | 51 |
|
28 | | - * For Windows: |
29 | | - ``` |
30 | | - set BROWSERSTACK_USERNAME=<browserstack-username> |
31 | | - set BROWSERSTACK_ACCESS_KEY=<browserstack-access-key> |
32 | | - ``` |
| 52 | +## Additional Resources |
33 | 53 |
|
34 | | -## To run tests |
35 | | -### Single test |
36 | | -Run single test session by running. |
37 | | -``` |
38 | | -php scripts/single.php |
39 | | -``` |
40 | | -### Parallel test |
41 | | -Run parallel test session by running. |
42 | | -``` |
43 | | -php scripts/parallel.php |
44 | | -``` |
45 | | -### Local test |
46 | | -Run local test session by running. |
47 | | -``` |
48 | | -php scripts/local.php |
49 | | -``` |
| 54 | +- [Documentation for writing Automate test scripts in PHP](https://www.browserstack.com/automate/php) |
| 55 | +- [Customizing your tests on BrowserStack](https://www.browserstack.com/automate/capabilities) |
| 56 | +- [Browsers & mobile devices for selenium testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms?product=automate) |
| 57 | +- [Using REST API to access information about your tests via the command-line interface](https://www.browserstack.com/automate/rest-api) |
0 commit comments