Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel execution accross browsers #5

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ def after_all(context):
```bash
behave features/test.feature
```

**Step 8:** The tests can be executed in the terminal parallel using behavex via tags.
```bash
behavex -t @Firefox,@Chrome,@Edge --parallel-processes 3
```
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. [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build) will help you view all your text logs, screenshots and video recording for your entire automation tests.

## Testing Locally Hosted or Privately Hosted Projects
Expand Down
17 changes: 8 additions & 9 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[
{
"platform": "Windows 10",
"browserName": "chrome",
"version": "latest",
"build": "Behave Selenium Sample",
"name": "Behave Sample Test"
}
]

{
"platform": "Windows 10",
"browserName": "chrome",
"version": "latest",
"build": "Behave Selenium Sample",
"name": "Behave Sample Test"
}
]
19 changes: 17 additions & 2 deletions features/environment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from behave.model_core import Status
from selenium import webdriver
import os
import json
Expand All @@ -15,15 +16,29 @@
authkey = os.environ["LT_ACCESS_KEY"]


def before_feature(context, feature):
def before_scenario(context, feature):
4DvAnCeBoY marked this conversation as resolved.
Show resolved Hide resolved
desired_cap = setup_desired_cap(CONFIG[INDEX])
if 'Chrome' in feature.tags:
desired_cap["browserName"] = "chrome"
desired_cap["platform"] = "Windows 11"
elif 'Firefox' in feature.tags:
desired_cap["browserName"] = "firefox"
desired_cap["platform"] = "Windows 10"
elif 'Edge' in feature.tags:
desired_cap["browserName"] = "edge"
desired_cap["platform"] = "Windows 8"

context.browser = webdriver.Remote(
desired_capabilities=desired_cap,
command_executor="https://%s:%[email protected]:443/wd/hub" % (username, authkey)
)


def after_feature(context, feature):
def after_scenario(context, scenario):
if scenario.status == Status.failed:
context.browser.execute_script("lambda-status=failed")
else:
context.browser.execute_script("lambda-status=passed")
context.browser.quit()


Expand Down
2 changes: 2 additions & 0 deletions features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Selenium steps to configure behave test scenarios
"""
import time
from behave import *


@when('visit url "{url}"')
def step(context, url):
Expand Down
24 changes: 22 additions & 2 deletions features/test.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
Feature: Automate a website
Scenario: perform click events

@Chrome
Scenario: perform click events with Chrome
When visit url "https://lambdatest.github.io/sample-todo-app"
When check if title is "Sample page - lambdatest.com"
When field with name "First Item" is present check the box
When field with name "Second Item" is present check the box
When select the textbox add "Let's add new to do item" in the box
When select the textbox add "Let's add new to do item for chrome" in the box
Then click the "addbutton"

@Firefox
Scenario: perform click events with Firefox
When visit url "https://lambdatest.github.io/sample-todo-app"
When check if title is "Sample page - lambdatest.com"
When field with name "First Item" is present check the box
When field with name "Second Item" is present check the box
When select the textbox add "Let's add new to do item for Firefox" in the box
Then click the "addbutton"

@Edge
Scenario: perform click events with Edge
When visit url "https://lambdatest.github.io/sample-todo-app"
When check if title is "Sample page - lambdatest.com"
When field with name "First Item" is present check the box
When field with name "Second Item" is present check the box
When select the textbox add "Let's add new to do item for Edge" in the box
Then click the "addbutton"
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Paver==1.3.4
selenium<4.0.0
behave==1.2.6
behave==1.2.6
behavex==1.6.0