0

I spent about one week trying to make my Robot Framework tests work for Safari browser in MacOS, when launched by Jenkins via ssh.

The main issue was that Robot couldn't open a browser when executed in ssh session, reporting "No browser is open".

  • MacOS 10.12.6 Sierra (issue was there also with 10.14 Mojave)
  • Safari 12.1.2 (issue was there also with Safari 10)
  • Robot Framework 3.1.2 (Python 3.6.8 / Python 2.7.16)

My current workaround is:

  1. Application "robot_test" created (in Automator based on shell script type) which is to launch a shell script and save the exit code:
/tmp/execute_test.sh > /tmp/execute_test.log 2>&1 
echo "export EXITCODE=$?" > /tmp/execute_test.result
  1. On the Jenkins side, in the shell command section, I am creating an shell script with the contents I need, execute it and wait for result file to appear:
export CURRENT_FOLDER=`pwd`
echo "#!/bin/bash
~/.bash_profile
cd $CURRENT_FOLDER
python3 -m robot -parameters robot_script.robot
" > /tmp/execute_test.sh
chmod +x /tmp/execute_test.sh     
rm -f /tmp/execute_test.result
MAX_WAIT_TIME=1200
WAIT_TIME=0
open -a robot_test > /tmp/robot_test_app.log 2>&1
while [ ! -f /tmp/execute_test.result ] && [ $WAIT_TIME -le $MAX_WAIT_TIME ]; do
  WAIT_TIME=$((WAIT_TIME+10)); sleep 10
done
cat /tmp/execute_test.log

EXITCODE=1
if [ -f /tmp/execute_test.result ]; then
  chmod +x /tmp/execute_test.result
  source /tmp/execute_test.result
fi
exit $EXITCODE

Am I the only one having problems with running robot test from ssh sessions in MacOS? If yes, could you please share you steps to configure the proper setup? If no, then this post might be helpful for someone to have working configuration at least, please share your solutions/workarounds if they are better.

1
  • Ok, just for everyone's info - the issue is gone after upgrading to the latest MacOS Catalina (10.15). There are some new problems with newer Safari, but it is another story :)
    – Vladimir T
    Nov 6, 2019 at 8:42

1 Answer 1

1

Do you run selenium as a separate process?
I had the same issue if you are not running selenium in the background.

(edit) Try java -jar selenium-XX.XX.jar in terminal.

After that run pabot or robot command to run the tests. You can crate app through the Automator and use the same approach you describe to call it from the CI. That is what I end up using.

1
  • Please add the commands you were running.
    – 030
    Dec 5, 2019 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.