Running tests in Grid and with different combinations of browsers and operating systems will need a few tweaks to the tests that we created earlier. We specified hardcoded browser and platform names in the desired capabilities. If we hardcode the values, then we will end up having a separate script for each combination. To avoid this and use a single test that will work on all the combinations, we need to parameterize the browser and platform values passed to the desired capabilities class as given in the following steps:
We will pass the browser and platform to the tests from the command line. For example, if we want to run test on the Windows and Chrome combination we will run the script through the command line in the following way:
python grid_test.py WINDOWS chrome
If we want to run tests on Safari on Mac, we can use following command:
python grid_test.py MAC safari
To implement this, we need to add two global attributes,
PLATFORM
andBROWSER
, to the test class...