|
1 | | -# Codeception Selenium Sample |
2 | | - |
3 | | - |
4 | | - |
5 | | -### Prerequisites |
6 | | -1. Install Php and setup environment variables. |
7 | | --Windows |
8 | | - * You can download PHP for Windows from http://windows.php.net/download/ |
9 | | - * Run the installer and follow the setup wizard to install PHP. |
10 | | - * Make sure you can use PHP with your command line: http://php.net/manual/en/install.windows.php |
11 | | - -Linux |
12 | | - * sudo apt-get install curl libcurl3 libcurl3-dev php |
13 | | - -Mac |
14 | | - * PHP should already be present on Mac OS X by default |
15 | | -2) Install Composer ([Linux/MacOS](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos), [Windows](https://getcomposer.org/doc/00-intro.md#installation-windows)) |
16 | | -3) Install MBstring extension. |
17 | | - |
18 | | -### Run your First Test |
19 | | -1. Clone the Codeception-selenium-sample repository. |
20 | | -``` |
21 | | -git clone https://github.com/LambdaTest/codeception-selenium-sample.git |
22 | | -``` |
23 | | -2. Next get into Codeception-selenium-sample folder, and import Lamabdatest Credentials. You can get these from lambdatest automation dashboard. |
24 | | - <p align="center"> |
25 | | - <b>For Linux/macOS:</b>: |
26 | | - |
| 1 | +# Run Selenium Tests With Codeception On LambdaTest |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +<p align="center"> |
| 7 | + <a href="https://www.lambdatest.com/blog/?utm_source=github&utm_medium=repo&utm_campaign=codeception-selenium-sample" target="_bank">Blog</a> |
| 8 | + ⋅ |
| 9 | + <a href="https://www.lambdatest.com/support/docs/?utm_source=github&utm_medium=repo&utm_campaign=codeception-selenium-sample" target="_bank">Docs</a> |
| 10 | + ⋅ |
| 11 | + <a href="https://www.lambdatest.com/learning-hub/?utm_source=github&utm_medium=repo&utm_campaign=codeception-selenium-sample" target="_bank">Learning Hub</a> |
| 12 | + ⋅ |
| 13 | + <a href="https://www.lambdatest.com/newsletter/?utm_source=github&utm_medium=repo&utm_campaign=codeception-selenium-sample" target="_bank">Newsletter</a> |
| 14 | + ⋅ |
| 15 | + <a href="https://www.lambdatest.com/certifications/?utm_source=github&utm_medium=repo&utm_campaign=codeception-selenium-sample" target="_bank">Certifications</a> |
| 16 | + ⋅ |
| 17 | + <a href="https://www.youtube.com/c/LambdaTest" target="_bank">YouTube</a> |
| 18 | +</p> |
| 19 | +  |
| 20 | +  |
| 21 | +  |
| 22 | + |
| 23 | +*Learn how to use Codeception framework to configure and run your PHP automation testing scripts on the LambdaTest platform* |
| 24 | + |
| 25 | +## Table Of Contents |
| 26 | + |
| 27 | +* [Pre-requisites](#pre-requisites) |
| 28 | +* [Run Your First Test](#run-your-first-test) |
| 29 | +* [Local Testing With Codeception](#testing-locally-hosted-or-privately-hosted-projects) |
| 30 | + |
| 31 | +## Prerequisites |
| 32 | + |
| 33 | +Before you begin automation testing with Selenium and Codeception, you would need to: |
| 34 | + |
| 35 | +* Make sure that you have the latest **PHP** installed on your system. You can download and install **PHP** using following commands in the terminal: |
| 36 | + |
| 37 | +* **MacOS:** Previous versions of **MacOS** have **PHP** installed by default. But for the latest **MacOS** versions starting with **Monterey**, **PHP** has to be downloaded and installed manually by using below commands: |
| 38 | + |
| 39 | + ```bash |
| 40 | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 41 | + brew install php |
| 42 | + ``` |
| 43 | +* **Windows:** |
| 44 | + |
| 45 | + ```bash |
| 46 | + sudo apt-get install curl libcurl3 libcurl3-dev php |
| 47 | + ``` |
| 48 | + |
| 49 | +**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 Command Prompt(cmd). |
| 50 | + |
| 51 | +* Download **composer** in the project directory ([Linux/MacOS](https://getcomposer.org/download/), [Windows](https://getcomposer.org/doc/00-intro.md#installation-windows)). |
| 52 | + |
| 53 | +**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: |
| 54 | + |
| 55 | + ```bash |
| 56 | + mv composer.phar /usr/local/bin/composer |
| 57 | + ``` |
| 58 | + |
| 59 | +### Installing Selenium Dependencies And Tutorial Repo |
| 60 | + |
| 61 | +**Step 1:** Clone the LambdaTest Codeception-selenium-sample repository and navigate to the code directory as shown below: |
| 62 | + |
| 63 | +```bash |
| 64 | +git clone https://github.com/LambdaTest/codeception-selenium-sample |
| 65 | +cd codeception-selenium-sample |
27 | 66 | ``` |
28 | | -export LT_USERNAME="YOUR_USERNAME" |
29 | | -export LT_ACCESS_KEY="YOUR ACCESS KEY" |
| 67 | + |
| 68 | +**Step 2:** Install the composer dependencies in the current project directory using the command below: |
| 69 | +```bash |
| 70 | +composer install |
30 | 71 | ``` |
31 | | -<p align="center"> |
32 | | - <b>For Windows:</b> |
33 | 72 |
|
| 73 | +### Setting Up Your Authentication |
| 74 | + |
| 75 | +Make sure you have your LambdaTest credentials with you to run test automation scripts. You can get these credentials from the [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build) or by your [LambdaTest Profile](https://accounts.lambdatest.com/login). |
| 76 | + |
| 77 | +**Step 3:** Set LambdaTest `Username` and `Access Key` in environment variables. |
| 78 | + |
| 79 | + * For **Linux/macOS**: |
| 80 | + ```bash |
| 81 | + export LT_USERNAME="YOUR_USERNAME" export LT_ACCESS_KEY="YOUR ACCESS KEY" |
| 82 | + ``` |
| 83 | + |
| 84 | + * For **Windows**: |
| 85 | + ```bash |
| 86 | + set LT_USERNAME="YOUR_USERNAME" set LT_ACCESS_KEY="YOUR ACCESS KEY" |
| 87 | + ``` |
| 88 | + |
| 89 | +## Run Your First Test |
| 90 | + |
| 91 | + |
| 92 | +>**Test Scenario**: Check out the sample acceptance [FirstCest.php](https://github.com/LambdaTest/codeception-selenium-sample/blob/master/tests/acceptance/FirstCest.php) file. |
| 93 | +
|
| 94 | +### Configuration Of Your Test Capabilities |
| 95 | + |
| 96 | +**Step 4:** Refer to the [acceptance.yml](https://github.com/LambdaTest/codeception-selenium-sample/blob/master/tests/acceptance.suite.yml) file to update your test capabilities. |
| 97 | + |
| 98 | +Notice the declaration of class name **“AcceptanceTester”**. We used this class to specify test configuration, port number, browser name, browser version and other desired capabilities. |
| 99 | + |
| 100 | +> **Note:** You can generate capabilities for your test requirements with the help of **[Desired Capability Generator](https://www.lambdatest.com/capabilities-generator/)**. |
| 101 | +
|
| 102 | +### Executing the Test |
| 103 | + |
| 104 | +**Step 5:** The tests can be executed in the terminal using the following command: |
| 105 | + |
| 106 | +```bash |
| 107 | +./vendor/bin/codecept run --steps |
34 | 108 | ``` |
35 | | -set LT_USERNAME="YOUR_USERNAME" |
36 | | -set LT_ACCESS_KEY="YOUR ACCESS KEY" |
| 109 | + |
| 110 | +Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build). |
| 111 | + |
| 112 | +## Testing Locally Hosted Or Privately Hosted Projects |
| 113 | + |
| 114 | +You can test your locally hosted or privately hosted projects with LambdaTest Selenium grid using LambdaTest Tunnel. All you would have to do is set up an SSH tunnel using tunnel and pass toggle `tunnel = True` via desired capabilities. LambdaTest Tunnel establishes a secure SSH protocol based tunnel that allows you in testing your locally hosted or privately hosted pages, even before they are live. |
| 115 | + |
| 116 | +Refer our [LambdaTest Tunnel documentation](https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/) for more information. |
| 117 | + |
| 118 | +Here’s how you can establish LambdaTest Tunnel. |
| 119 | + |
| 120 | +Download the binary file of: |
| 121 | +* [LambdaTest Tunnel for Windows](https://downloads.lambdatest.com/tunnel/v3/windows/64bit/LT_Windows.zip) |
| 122 | +* [LambdaTest Tunnel for macOS](https://downloads.lambdatest.com/tunnel/v3/mac/64bit/LT_Mac.zip) |
| 123 | +* [LambdaTest Tunnel for Linux](https://downloads.lambdatest.com/tunnel/v3/linux/64bit/LT_Linux.zip) |
| 124 | + |
| 125 | +Open command prompt and navigate to the binary folder. |
| 126 | + |
| 127 | +Run the following command: |
| 128 | + |
| 129 | +```bash |
| 130 | +LT -user {user’s login email} -key {user’s access key} |
37 | 131 | ``` |
38 | | -Step 3. Install dependencies by composer. |
| 132 | +So if your user name is lambdatest@example.com and key is 123456, the command would be: |
| 133 | + |
| 134 | +```bash |
| 135 | +LT -user lambdatest@example.com -key 123456 |
39 | 136 | ``` |
40 | | -composer install |
| 137 | +Once you are able to connect **LambdaTest Tunnel** successfully, you would just have to pass on tunnel capabilities in the code shown below : |
| 138 | + |
| 139 | +**Tunnel Capability** |
| 140 | + |
41 | 141 | ``` |
42 | | -Step 4. To run a single test, run |
43 | | -``` |
44 | | -./vendor/bin/codecept run --steps |
| 142 | +DesiredCapabilities capabilities = new DesiredCapabilities(); |
| 143 | + capabilities.setCapability("tunnel", true); |
45 | 144 | ``` |
46 | 145 |
|
47 | | -##### Routing traffic through your local machine |
48 | | -- Set tunnel value to `true` in test capabilities |
49 | | -> OS specific instructions to download and setup tunnel binary can be found at the following links. |
50 | | -> - [Windows](https://www.lambdatest.com/support/docs/display/TD/Local+Testing+For+Windows) |
51 | | -> - [Mac](https://www.lambdatest.com/support/docs/display/TD/Local+Testing+For+MacOS) |
52 | | -> - [Linux](https://www.lambdatest.com/support/docs/display/TD/Local+Testing+For+Linux) |
| 146 | +## Additional Links |
| 147 | +*** |
| 148 | +* [Advanced Configuration for Capabilities](https://www.lambdatest.com/support/docs/selenium-automation-capabilities/) |
| 149 | +* [How to test locally hosted apps](https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/) |
| 150 | +* [How to integrate LambdaTest with CI/CD](https://www.lambdatest.com/support/docs/integrations-with-ci-cd-tools/) |
| 151 | + |
| 152 | +## Documentation & Resources :books: |
| 153 | + |
| 154 | + |
| 155 | +Visit the following links to learn more about LambdaTest's features, setup and tutorials around test automation, mobile app testing, responsive testing, and manual testing. |
| 156 | + |
| 157 | +* [LambdaTest Documentation](https://www.lambdatest.com/support/docs/?utm_source=github&utm_medium=repo&utm_campaign=codeception-selenium-sample) |
| 158 | +* [LambdaTest Blog](https://www.lambdatest.com/blog/?utm_source=github&utm_medium=repo&utm_campaign=codeception-selenium-sample) |
| 159 | +* [LambdaTest Learning Hub](https://www.lambdatest.com/learning-hub/?utm_source=github&utm_medium=repo&utm_campaign=codeception-selenium-sample) |
53 | 160 |
|
54 | | -### Important Note: |
55 | | -Some Safari & IE browsers, doesn't support automatic resolution of the URL string "localhost". Therefore if you test on URLs like "http://localhost/" or "http://localhost:8080" etc, you would get an error in these browsers. A possible solution is to use "localhost.lambdatest.com" or replace the string "localhost" with machine IP address. For example if you wanted to test "http://localhost/dashboard" or, and your machine IP is 192.168.2.6 you can instead test on "http://192.168.2.6/dashboard" or "http://localhost.lambdatest.com/dashboard". |
| 161 | +## LambdaTest Community :busts_in_silhouette: |
56 | 162 |
|
| 163 | +The [LambdaTest Community](https://community.lambdatest.com/) allows people to interact with tech enthusiasts. Connect, ask questions, and learn from tech-savvy people. Discuss best practises in web development, testing, and DevOps with professionals from across the globe 🌎 |
| 164 | + |
| 165 | +## What's New At LambdaTest ❓ |
| 166 | + |
| 167 | +To stay updated with the latest features and product add-ons, visit [Changelog](https://changelog.lambdatest.com/) |
| 168 | + |
57 | 169 | ## About LambdaTest |
58 | 170 |
|
59 | | -[LambdaTest](https://www.lambdatest.com/) is a cloud based selenium grid infrastructure that can help you run automated cross browser compatibility tests on 2000+ different browser and operating system environments. LambdaTest supports all programming languages and frameworks that are supported with Selenium, and have easy integrations with all popular CI/CD platforms. It's a perfect solution to bring your [selenium automation testing](https://www.lambdatest.com/selenium-automation) to cloud based infrastructure that not only helps you increase your test coverage over multiple desktop and mobile browsers, but also allows you to cut down your test execution time by running tests on parallel. |
60 | | -### Resources |
| 171 | +[LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=codeception-selenium-sample) is a leading test execution and orchestration platform that is fast, reliable, scalable, and secure. It allows users to run both manual and automated testing of web and mobile apps across 3000+ different browsers, operating systems, and real device combinations. Using LambdaTest, businesses can ensure quicker developer feedback and hence achieve faster go to market. Over 500 enterprises and 1 Million + users across 130+ countries rely on LambdaTest for their testing needs. |
| 172 | + |
| 173 | +### Features |
| 174 | + |
| 175 | +* Run Selenium, Cypress, Puppeteer, Playwright, and Appium automation tests across 3000+ real desktop and mobile environments. |
| 176 | +* Real-time cross browser testing on 3000+ environments. |
| 177 | +* Test on Real device cloud |
| 178 | +* Blazing fast test automation with HyperExecute |
| 179 | +* Accelerate testing, shorten job times and get faster feedback on code changes with Test At Scale. |
| 180 | +* Smart Visual Regression Testing on cloud |
| 181 | +* 120+ third-party integrations with your favorite tool for CI/CD, Project Management, Codeless Automation, and more. |
| 182 | +* Automated Screenshot testing across multiple browsers in a single click. |
| 183 | +* Local testing of web and mobile apps. |
| 184 | +* Online Accessibility Testing across 3000+ desktop and mobile browsers, browser versions, and operating systems. |
| 185 | +* Geolocation testing of web and mobile apps across 53+ countries. |
| 186 | +* LT Browser - for responsive testing across 50+ pre-installed mobile, tablets, desktop, and laptop viewports |
| 187 | + |
| 188 | + |
| 189 | +[<img height="70" src="https://user-images.githubusercontent.com/70570645/169649126-ed61f6de-49b5-4593-80cf-3391ca40d665.PNG">](https://accounts.lambdatest.com/register) |
| 190 | + |
| 191 | + |
| 192 | + |
| 193 | +## We are here to help you :headphones: |
61 | 194 |
|
62 | | -##### [SeleniumHQ Documentation](http://www.seleniumhq.org/docs/) |
63 | | -##### [PhpUnit Documentation](https://phpunit.de/documentation.html) |
| 195 | +* Got a query? we are available 24x7 to help. [Contact Us](support@lambdatest.com) |
| 196 | +* For more info, visit - [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=codeception-selenium-sample) |
0 commit comments