How To Get The Result Of A Ran Robot File Using Popen
I want to be able to retrieve the result (whether it passed or it failed) of the robot test that is ran using popen. I want to use popen to support dialog boxes and tests that are not dialog boxes. Is there any way to retrieve the result? I am using the code from this page here (link).
import sys
import subprocess
my_path = sys.executable
def run_process(command):
print("Running command: " + command)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
while True:
if sys.version_info >= (3, 0):
nextline = str(p.stdout.readline(),"utf-8")
else:
nextline = p.stdout.readline()
if nextline == '' and p.poll() is not None:
break
sys.stdout.write(nextline)
sys.stdout.flush()
python_path = my_path + ' -m robot.run'
Location ='C:/Users/Desktop/pass_or_fail.robot'
command=python_path+' '+Location
run_process(command)
print(my_path)
python robotframework
add a comment |
I want to be able to retrieve the result (whether it passed or it failed) of the robot test that is ran using popen. I want to use popen to support dialog boxes and tests that are not dialog boxes. Is there any way to retrieve the result? I am using the code from this page here (link).
import sys
import subprocess
my_path = sys.executable
def run_process(command):
print("Running command: " + command)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
while True:
if sys.version_info >= (3, 0):
nextline = str(p.stdout.readline(),"utf-8")
else:
nextline = p.stdout.readline()
if nextline == '' and p.poll() is not None:
break
sys.stdout.write(nextline)
sys.stdout.flush()
python_path = my_path + ' -m robot.run'
Location ='C:/Users/Desktop/pass_or_fail.robot'
command=python_path+' '+Location
run_process(command)
print(my_path)
python robotframework
Can you highlight what is not working for you? I.e. what’s the error you’re facing?
– A. Kootstra
Nov 13 '18 at 16:50
add a comment |
I want to be able to retrieve the result (whether it passed or it failed) of the robot test that is ran using popen. I want to use popen to support dialog boxes and tests that are not dialog boxes. Is there any way to retrieve the result? I am using the code from this page here (link).
import sys
import subprocess
my_path = sys.executable
def run_process(command):
print("Running command: " + command)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
while True:
if sys.version_info >= (3, 0):
nextline = str(p.stdout.readline(),"utf-8")
else:
nextline = p.stdout.readline()
if nextline == '' and p.poll() is not None:
break
sys.stdout.write(nextline)
sys.stdout.flush()
python_path = my_path + ' -m robot.run'
Location ='C:/Users/Desktop/pass_or_fail.robot'
command=python_path+' '+Location
run_process(command)
print(my_path)
python robotframework
I want to be able to retrieve the result (whether it passed or it failed) of the robot test that is ran using popen. I want to use popen to support dialog boxes and tests that are not dialog boxes. Is there any way to retrieve the result? I am using the code from this page here (link).
import sys
import subprocess
my_path = sys.executable
def run_process(command):
print("Running command: " + command)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
while True:
if sys.version_info >= (3, 0):
nextline = str(p.stdout.readline(),"utf-8")
else:
nextline = p.stdout.readline()
if nextline == '' and p.poll() is not None:
break
sys.stdout.write(nextline)
sys.stdout.flush()
python_path = my_path + ' -m robot.run'
Location ='C:/Users/Desktop/pass_or_fail.robot'
command=python_path+' '+Location
run_process(command)
print(my_path)
python robotframework
python robotframework
asked Nov 13 '18 at 15:27
S.McWhorterS.McWhorter
818
818
Can you highlight what is not working for you? I.e. what’s the error you’re facing?
– A. Kootstra
Nov 13 '18 at 16:50
add a comment |
Can you highlight what is not working for you? I.e. what’s the error you’re facing?
– A. Kootstra
Nov 13 '18 at 16:50
Can you highlight what is not working for you? I.e. what’s the error you’re facing?
– A. Kootstra
Nov 13 '18 at 16:50
Can you highlight what is not working for you? I.e. what’s the error you’re facing?
– A. Kootstra
Nov 13 '18 at 16:50
add a comment |
1 Answer
1
active
oldest
votes
If the tests passes or fails it can be stored as an integer. For example, a 0 represents that the test passed and anything greater than 0 represents that the test failed. That's why I used:
output = p.communicate()[0]
rc = p.returncode
import sys
import subprocess
my_path = sys.executable
def run_process(command):
global output
global rc
print("Running command: " + command)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
while True:
if sys.version_info >= (3, 0):
nextline = str(p.stdout.readline(),"utf-8")
else:
nextline = p.stdout.readline()
if nextline == '' and p.poll() is not None:
break
sys.stdout.write(nextline)
sys.stdout.flush()
output = p.communicate()[0]
rc = p.returncode
python_path = my_path + ' -m robot.run'
Location ='C:/Users/Desktop/pass_or_fail.robot'
command=python_path+' '+Location
run_process(command)
print(my_path)
print(rc)
1
The return code is the number of failed cases - 0 means zero failed, X - that X failed. If your suite had a single case, that may have mislead you into thinking the RC is either 0 or 1. There's some more info in the user guide.
– Todor Minakov
Nov 13 '18 at 17:44
Good catch, thank you!
– S.McWhorter
Nov 13 '18 at 17:55
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284292%2fhow-to-get-the-result-of-a-ran-robot-file-using-popen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If the tests passes or fails it can be stored as an integer. For example, a 0 represents that the test passed and anything greater than 0 represents that the test failed. That's why I used:
output = p.communicate()[0]
rc = p.returncode
import sys
import subprocess
my_path = sys.executable
def run_process(command):
global output
global rc
print("Running command: " + command)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
while True:
if sys.version_info >= (3, 0):
nextline = str(p.stdout.readline(),"utf-8")
else:
nextline = p.stdout.readline()
if nextline == '' and p.poll() is not None:
break
sys.stdout.write(nextline)
sys.stdout.flush()
output = p.communicate()[0]
rc = p.returncode
python_path = my_path + ' -m robot.run'
Location ='C:/Users/Desktop/pass_or_fail.robot'
command=python_path+' '+Location
run_process(command)
print(my_path)
print(rc)
1
The return code is the number of failed cases - 0 means zero failed, X - that X failed. If your suite had a single case, that may have mislead you into thinking the RC is either 0 or 1. There's some more info in the user guide.
– Todor Minakov
Nov 13 '18 at 17:44
Good catch, thank you!
– S.McWhorter
Nov 13 '18 at 17:55
add a comment |
If the tests passes or fails it can be stored as an integer. For example, a 0 represents that the test passed and anything greater than 0 represents that the test failed. That's why I used:
output = p.communicate()[0]
rc = p.returncode
import sys
import subprocess
my_path = sys.executable
def run_process(command):
global output
global rc
print("Running command: " + command)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
while True:
if sys.version_info >= (3, 0):
nextline = str(p.stdout.readline(),"utf-8")
else:
nextline = p.stdout.readline()
if nextline == '' and p.poll() is not None:
break
sys.stdout.write(nextline)
sys.stdout.flush()
output = p.communicate()[0]
rc = p.returncode
python_path = my_path + ' -m robot.run'
Location ='C:/Users/Desktop/pass_or_fail.robot'
command=python_path+' '+Location
run_process(command)
print(my_path)
print(rc)
1
The return code is the number of failed cases - 0 means zero failed, X - that X failed. If your suite had a single case, that may have mislead you into thinking the RC is either 0 or 1. There's some more info in the user guide.
– Todor Minakov
Nov 13 '18 at 17:44
Good catch, thank you!
– S.McWhorter
Nov 13 '18 at 17:55
add a comment |
If the tests passes or fails it can be stored as an integer. For example, a 0 represents that the test passed and anything greater than 0 represents that the test failed. That's why I used:
output = p.communicate()[0]
rc = p.returncode
import sys
import subprocess
my_path = sys.executable
def run_process(command):
global output
global rc
print("Running command: " + command)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
while True:
if sys.version_info >= (3, 0):
nextline = str(p.stdout.readline(),"utf-8")
else:
nextline = p.stdout.readline()
if nextline == '' and p.poll() is not None:
break
sys.stdout.write(nextline)
sys.stdout.flush()
output = p.communicate()[0]
rc = p.returncode
python_path = my_path + ' -m robot.run'
Location ='C:/Users/Desktop/pass_or_fail.robot'
command=python_path+' '+Location
run_process(command)
print(my_path)
print(rc)
If the tests passes or fails it can be stored as an integer. For example, a 0 represents that the test passed and anything greater than 0 represents that the test failed. That's why I used:
output = p.communicate()[0]
rc = p.returncode
import sys
import subprocess
my_path = sys.executable
def run_process(command):
global output
global rc
print("Running command: " + command)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
while True:
if sys.version_info >= (3, 0):
nextline = str(p.stdout.readline(),"utf-8")
else:
nextline = p.stdout.readline()
if nextline == '' and p.poll() is not None:
break
sys.stdout.write(nextline)
sys.stdout.flush()
output = p.communicate()[0]
rc = p.returncode
python_path = my_path + ' -m robot.run'
Location ='C:/Users/Desktop/pass_or_fail.robot'
command=python_path+' '+Location
run_process(command)
print(my_path)
print(rc)
edited Nov 13 '18 at 17:54
answered Nov 13 '18 at 17:04
S.McWhorterS.McWhorter
818
818
1
The return code is the number of failed cases - 0 means zero failed, X - that X failed. If your suite had a single case, that may have mislead you into thinking the RC is either 0 or 1. There's some more info in the user guide.
– Todor Minakov
Nov 13 '18 at 17:44
Good catch, thank you!
– S.McWhorter
Nov 13 '18 at 17:55
add a comment |
1
The return code is the number of failed cases - 0 means zero failed, X - that X failed. If your suite had a single case, that may have mislead you into thinking the RC is either 0 or 1. There's some more info in the user guide.
– Todor Minakov
Nov 13 '18 at 17:44
Good catch, thank you!
– S.McWhorter
Nov 13 '18 at 17:55
1
1
The return code is the number of failed cases - 0 means zero failed, X - that X failed. If your suite had a single case, that may have mislead you into thinking the RC is either 0 or 1. There's some more info in the user guide.
– Todor Minakov
Nov 13 '18 at 17:44
The return code is the number of failed cases - 0 means zero failed, X - that X failed. If your suite had a single case, that may have mislead you into thinking the RC is either 0 or 1. There's some more info in the user guide.
– Todor Minakov
Nov 13 '18 at 17:44
Good catch, thank you!
– S.McWhorter
Nov 13 '18 at 17:55
Good catch, thank you!
– S.McWhorter
Nov 13 '18 at 17:55
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284292%2fhow-to-get-the-result-of-a-ran-robot-file-using-popen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you highlight what is not working for you? I.e. what’s the error you’re facing?
– A. Kootstra
Nov 13 '18 at 16:50