How can I test for multiple browsers at once in browserstack through node? - browserstack

I'm a beginner to browserStack and wanted to know if I can test for multiple browsers at once. I have an account which provides 100 minutes of free service. I'm using it to test a small application in Chrome(below are the capabilities)
'browserName': 'Chrome',
'browser_version': '62.0',
'os': '62.0',
'os_version': '10',
'resolution': '1366x768',
'browserstack.user': 'xxx',
'browserstack.key': 'yyy',
'name': 'Bstack-[Node] Sample Test',
'browserstack.debug': true,
'browserstack.local': true,
'acceptSslCerts': true
}```
It would be of great help if anyone insisted me on having it to extend for multiple browsers and different versions in a single execution.

You can use MakeFile with multiple platform or browser combinations as parallel jobs and then run the MakeFile. This is the easiest way to run tests in parallel in Browserstack. I have done this using java it works as charm. And MakeFile works with any programming language.
Below is a sample MakeFile.
browserstack_parallel:
make -j bs_windows_10_firefox_69 bs_windows_8.1_ie_11
bs_windows_10_firefox_69:
mvn test -Dbs_local_testing=false -Dbs_browser=Firefox -Dbs_browser_version=69.0 -Dbs_os=Windows -Dbs_os_version=10 -Dbs_selenium_version=3.141.59
bs_windows_8.1_ie_11:
mvn test -Dbs_local_testing=false -Dbs_browser=IE -Dbs_browser_version=11.0 -Dbs_os=Windows -Dbs_os_version=8.1 -Dbs_selenium_version=3.141.59
For running this MakeFile run the command
make browserstack_parallel

Used parallel testing which would test for multiple browsers in a single execution

Related

Is it possible to execute cucumber scenario's in parallel on different browsers(chrome and firefox) at same time?

I succeeded to run cucumber scenario's in parallel but only on one browsertype(chrome or firefox). So first I run my tests on chrome. When tests finish I start a second test run on firefox.
Is it possible to run cucumber scenarios in parallel on different browsertypes at same time?
See cucumber bdd documentation how to achieve parallel execution of scenarios at https://cucumber.io/docs/guides/parallel-execution/
I use testNG as testrunner!
Thanks a lot for your responses!
You are running a your tests against a matrix of browsers. Typically this matrix configured in CI and provided to the test execution via environment variables. For example using Gitlab CI Matrix:
test:
stage: test
script:
- mvn test
parallel:
matrix:
- OS: Windows
OS_VERSION: 10
BROWSER: [Chrome, Firefox, Edge]
- OS: OS X
OS_VERSION: Big Sur
BROWSER: [Chrome, Firefox, Edge, Safari]
You then create the web driver in the before hook using the environment variables.
#Before
public void before(Scenario scenario){
String os = System.getenv("OS");
String osVersion = System.getenv("OS_VERSION");
String browser = System.getenv("BROWSER");
driver = createDriver(os, osVersion, browser);
}
You could also use Maven Profiles or Gradle Tasks to define these different sets of environment variables.
However key is to let these jobs in parallel on your CI system by starting multiple JVMs rather then only in Cucumber by starting multiple threads.
See the following answer Is it posible to run feature cucumber in parallel in different browser
This link at https://github.com/prashant-ramcharan/courgette-jvm-selenium explains how to achieve by using courgette-jvm(extension on cucumber-jvm).

How to distribute gtest tests execution using Incredibuild?

IncrediBuild states about new tests distribution feature. How to use it?
How to distribute gtest tests execution using Incredibuild?
cd <test_dir>
xgconsole /test=gtest /command="<the_test.exe>"
This causes to launch the exe tests on multiple nodes.
I am not sire if this is still relevant but IncrediBuild has an official unit testing solution so please refer to the following link:
https://docs.incredibuild.com/win/latest/windows/ibtestconsole_interface.html?Highlight=gtest
As you can see, there is a new dedicated command - ibtestconsole in order to invoke the tests.

How to run only failed tests (protractor+jasmine)

We have ~150 e2e tests and executing in multiple browsers like chrome, firefox, IE, Edge & Safari. Few tests are failing on different reasons. Is it possible to execute only failed tests using protractor?
Yes, You can use protractor-flake => https://www.npmjs.com/package/protractor-flake
It's able to rerun whole spec files. You actually can provide a parser which receives all test output. We use this and it's very helpful.

Running protractor test parallel on different environments

I would like to run my protractor test on different environments such as
testing it on local environment,
testing it on test environment,
testing it on production
environment and so on at the same time and using the same browser example chrome.
So in this case my base URL would change for every environment: When I run the test I would like to run it parallel on all the different environments.
baseUrl:'localhost:8080'
baseUrl:'tst.company.com'
baseUrl:'prod.company.com'
etc
and browser remains the same
multiCapabilities:[
{ 'browsername':'chrome',
'chromeOptions':{
'binary': 'drive:pathToChrome',
'args':'[]'
'extensions':[]
}
}]
Any one knows how to, on this cases.
Thanks
I would approach this with a task manager: grunt and grunt-parallel.
Create 3 separate grunt task configurations with different baseUrl settings (you would need grunt-protractor-runner package installed).

Integration Tests on Geb / Spock + Selenium Grid do not run in parallel

I have the following set-up: an integration tests project which has a suite of tests written in Groovy/Geb + Spock, which are running perfectly both using Selenium WebDriver and Selenium Grid (RemoteWebDriver).
The problem is that no matter how much I try to tweak the "system", I can't get the tests to run in parallel (i.e. although I have 3 slaves [nodes] registered to the hub, only one of the slaves actually receives the requests). I've enforced maxSession=1 to the Selenium nodes and tried different combinations of parallel=classes|methods, threadCount and fork settings in failsafe plugin configuration (pom.xml file).
I have the feeling that the problem lies somewhere between the maven configuration and selenium grid, probably in relation to Geb/Spock config.
Does any of you have any insight on this issue?
PS: someone suggested that running tests in parallel using Geb / Spock is not possible - because for some reason ?Geb? locks the JUnitRunner (not sure what this means).
Add following configuration to your build.gradle file:
tasks.withType(Test) {
maxParallelForks = 3 // here three forks shall open in parallel
forkEvery = 1
include '**/*TestName*.class' // name of your test class
}
There are test frameworks, TestNG for example, that support parallel testing on the method level out of the box.
Spock, as an example to the contrary, does not support it.
But you do not have to have multithreading implemented by your test framework to make this work.
You can use your build tool to run test classes in parallel, both Maven and Gradle support this.
If you are using Maven, this documentation page and examples might help you:
https://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html
Specifically have a look at "Forked Test Execution".
You can run it for sure, The point is you have to put them (your tests) in threads. Here is the link.