TestProject Forum
Powered by leading experts in the test automation community

Connecting 3 different Jobs together

Is there anyways to schedule 3 different jobs one after another in Test Project?
The scenario is:
Job 1 - Test that will do something on Web App on browser and generate a token
Job 2- Uses the generated token and do something on iOS native app and generate another token
Job 3 - Goes back to Web App on browser and validate the generated token in Job 2

Hello @rkhanna
Jobs execute as a Queue by default, so you can just run the job one after another from the UI or use the python script from here to do it for you:
How to run mobile test job with Rest API

The jobs will be executed one after another.

@ran.tzur I executed the python file with my data but got below error. Can you suggest what is wrong here?

Last login: Thu Dec 17 12:54:47 on ttys000
chruby: unknown Ruby: ruby-2.7.0
Rishis-MacBook-Pro% cd Documents
Rishis-MacBook-Pro% python jobs_modified.py
Traceback (most recent call last):
File “jobs_modified.py”, line 89, in
get_jobs_names()
File “jobs_modified.py”, line 61, in get_jobs_names
jobs_names[job_id] = get_job_name(job_id)
File “jobs_modified.py”, line 77, in get_job_name
response = requests.get(url, headers=header)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/api.py”, line 76, in get
return request(‘get’, url, params=params, **kwargs)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/sessions.py”, line 528, in request
prep = self.prepare_request(req)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/sessions.py”, line 466, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/models.py”, line 317, in prepare
self.prepare_headers(headers)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/models.py”, line 449, in prepare_headers
for header in headers.items():
AttributeError: ‘str’ object has no attribute ‘items’
Rishis-MacBook-Pro% python jobs_modified.py
Traceback (most recent call last):
File “jobs_modified.py”, line 89, in
get_jobs_names()
File “jobs_modified.py”, line 61, in get_jobs_names
jobs_names[job_id] = get_job_name(job_id)
File “jobs_modified.py”, line 77, in get_job_name
response = requests.get(url, headers=header)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/api.py”, line 76, in get
return request(‘get’, url, params=params, **kwargs)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/sessions.py”, line 528, in request
prep = self.prepare_request(req)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/sessions.py”, line 466, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/models.py”, line 317, in prepare
self.prepare_headers(headers)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/models.py”, line 449, in prepare_headers
for header in headers.items():
AttributeError: ‘str’ object has no attribute ‘items’
Rishis-MacBook-Pro% clr
zsh: command not found: clr
Rishis-MacBook-Pro% clear

Rishis-MacBook-Pro% python jobs_modified.py
Traceback (most recent call last):
File “jobs_modified.py”, line 89, in
get_jobs_names()
File “jobs_modified.py”, line 61, in get_jobs_names
jobs_names[job_id] = get_job_name(job_id)
File “jobs_modified.py”, line 77, in get_job_name
response = requests.get(url, headers=header)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/api.py”, line 76, in get
return request(‘get’, url, params=params, **kwargs)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/sessions.py”, line 528, in request
prep = self.prepare_request(req)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/sessions.py”, line 466, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/models.py”, line 317, in prepare
self.prepare_headers(headers)
File “/Users/rishikhanna/Library/Python/2.7/lib/python/site-packages/requests/models.py”, line 449, in prepare_headers
for header in headers.items():
AttributeError: ‘str’ object has no attribute ‘items’
Rishis-MacBook-Pro%

You need to edit the python file and put your API key there, as well as the Job IDs for all the Jobs you want to execute in order.

I did that and executed on python3. Still the same error
Last login: Thu Dec 17 15:56:32 on ttys000
chruby: unknown Ruby: ruby-2.7.0
Rishis-MacBook-Pro% cd Documents
Rishis-MacBook-Pro% python3 jobs_modified.py
File “/Users/rishikhanna/Documents/jobs_modified.py”, line 31
time.sleep(5)
IndentationError: unexpected indent
Rishis-MacBook-Pro% python3 jobs_modified.py
Traceback (most recent call last):
File “/Users/rishikhanna/Documents/jobs_modified.py”, line 1, in
import requests
ModuleNotFoundError: No module named ‘requests’
Rishis-MacBook-Pro% pip3 install requests
Collecting requests
Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting urllib3<1.27,>=1.21.1
Using cached urllib3-1.26.2-py2.py3-none-any.whl (136 kB)
Collecting certifi>=2017.4.17
Using cached certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Collecting idna<3,>=2.5
Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting chardet<5,>=3.0.2
Using cached chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Installing collected packages: urllib3, certifi, idna, chardet, requests
Successfully installed certifi-2020.12.5 chardet-4.0.0 idna-2.10 requests-2.25.1 urllib3-1.26.2
WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available.
You should consider upgrading via the ‘/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -m pip install --upgrade pip’ command.
Rishis-MacBook-Pro% python3 jobs_modified.py
Traceback (most recent call last):
File “/Users/rishikhanna/Documents/jobs_modified.py”, line 90, in
get_jobs_names()
File “/Users/rishikhanna/Documents/jobs_modified.py”, line 61, in get_jobs_names
jobs_names[job_id] = get_job_name(job_id)
File “/Users/rishikhanna/Documents/jobs_modified.py”, line 77, in get_job_name
response = requests.get(url, headers=header)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/api.py”, line 76, in get
return request(‘get’, url, params=params, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/sessions.py”, line 528, in request
prep = self.prepare_request(req)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/sessions.py”, line 456, in prepare_request
p.prepare(
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/models.py”, line 317, in prepare
self.prepare_headers(headers)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/models.py”, line 449, in prepare_headers
for header in headers.items():
AttributeError: ‘str’ object has no attribute ‘items’
Rishis-MacBook-Pro% clear

Rishis-MacBook-Pro% python3 jobs_modified.py
Traceback (most recent call last):
File “/Users/rishikhanna/Documents/jobs_modified.py”, line 90, in
get_jobs_names()
File “/Users/rishikhanna/Documents/jobs_modified.py”, line 61, in get_jobs_names
jobs_names[job_id] = get_job_name(job_id)
File “/Users/rishikhanna/Documents/jobs_modified.py”, line 77, in get_job_name
response = requests.get(url, headers=header)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/api.py”, line 76, in get
return request(‘get’, url, params=params, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/sessions.py”, line 528, in request
prep = self.prepare_request(req)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/sessions.py”, line 456, in prepare_request
p.prepare(
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/models.py”, line 317, in prepare
self.prepare_headers(headers)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/models.py”, line 449, in prepare_headers
for header in headers.items():
AttributeError: ‘str’ object has no attribute ‘items’
Rishis-MacBook-Pro%