I want to pass desired capabilities from jenkins to sauce lab
I have written my code in python
desired_caps = {}
desired_caps['platform'] = os.getenv('platform','SELENIUM_PLATFORM')
desired_caps['browserName'] = os.getenv('browserName','SELENIUM_BROWSER')
desired_caps['version'] = os.getenv('version','SELENIUM_VERSION')
context.browser = webdriver.Remote(
command_executor='http://USER_NAME:KEY@ondemand.saucelabs.com:80/wd/hub',
desired_capabilities=desired_caps)
Getting this error on jenkins while running the build:
Starting pre-build for Sauce Labs plugin
Finished pre-build for Sauce Labs plugin
$ cmd /c call C:\WINDOWS\TEMP\jenkins6037287030698812464.bat
selenium.common.exceptions.WebDriverException: Message: Misconfigured --
Unsupported OS/browser/version/device combo: OS: 'SELENIUM_PLATFORM',
Browser: 'selenium_browser', Version: 'SELENIUM_VERSION.', Device:
'unspecified'
Executing before all - creating benemax admin with owner permission to use it
everywhere
User data: {}
Exception WebDriverException: Message: Misconfigured -- Unsupported
OS/browser/version/device combo: OS: 'SELENIUM_PLATFORM', Browser:
'selenium_browser', Version: 'SELENIUM_VERSION.', Device: 'unspecified'
C:\Program Files (x86)\Jenkins\workspace\project>exit 1
Build step 'Execute Windows batch command' marked build as failure
Starting post-build for Sauce Labs plugin
Updating the custom data field for jobs with Jenkins build info for analytics
Stopped/completed/updated 0 jobs
Finished post-build for Sauce Labs plugin
Starting Sauce Labs test publisher
The Sauce OnDemand plugin is configured, but no session IDs were found in the
test output.
Finished Sauce Labs test publisher
Finished: FAILURE
You seem to be using os.getEnv
wrong.
os.getenv('version','SELENIUM_VERSION')
should most likely be just os.getenv('SELENIUM_VERSION')
The second parameter of the function is default value, the first is the environment variable you want to get. https://docs.python.org/3.7/library/os.html#os.getenv
Now what happens is that you try to get the value of an environment variable called version
, which does not exist, and then it defaults back to the literal string 'SELENIUM_VERSION'
.