How to reference yaml variable file present in github in robot framework test case file in github - azure-devops

I ran Robot framework test cases(present in github) through azure pipeline. Test cases executed fine. Next I modified robot framework test case file to import yaml variable file (variable yaml file also present in same github repo folder) which has variables to be used by test cases file.
yaml variable file looks like this
login:
url: xxx.com
email: abc#y.com
password: xyz
And my test cases file look like this
*** Settings ***
Library SeleniumLibrary
Variables variablesfile.yaml
*** Test Cases ***
Dev_TC01_AddProcess
Open Browser ${login.url} chrome
Input Text id=email ${login.email}
Input Password id=password ${login.password}
And my yaml pipeline to trigger test scenarios looks like this
- script: |
pip install pytest pytest-azurepipelines
pytest
robot --pythonpath . -x outputxunit.xml TestScenarios.robot
displayName: 'Run Robot Scripts'
but on running the pipeline I get error, because test scenarios file is unable to reference variablesfile.yaml. got error message - Resolving variable '${login.url}' failed:
Can you please suggest how to reference variable file

Above error seems to be caused by the variables yaml file not being found.
If you defined Variables file in the Settings section like what you defined in above example. You should put the variables yaml files in the same directory of the test robot file TestScenarios.robot.
If the variables files are not under the same directory. You can define the correct relative path in the Settings section like below example: See here.
Variables ../data/variables.yaml
Note:
Using YAML files with Robot Framework requires PyYAML module to be installed. If you have pip_ installed, you can install it simply by running pip install pyyaml.

Variables file is in the same directory of TestScenarios.robot. I also tried entering the full path still it didnt work. Finally i got a solution, I need to run pip install pyyaml script then it worked

Related

Unable to run/debug robot tests in vscode - robocorp extensions installed

I have installed Robocorp Code as well as Robot Framework Language Server and have configured them. However, I am still having errors when trying to run the tests via the code lens options.
Repo - A webapi repo with a specific folder containing all tests. Lets call it regression.
RF - 4.1.3
Python - 3.8
This is what happens when I click on Run on the code lens for any of the tests -
`PS C:\git\xxxx\regression> C:; cd 'C:\git\xxxx\regression'; &
'C:\Users\xxxx\AppData\Local\Temp\rf-ls-run\run_env_00_smh5defr.bat'
'-u'
'c:\Users\xxxx.vscode\extensions\robocorp.robotframework-lsp-0.47.2\src\robotframework_debug_adapter\run_robot__main__.py'
'--port' '54331' '--no-debug' '--argumentfile'
'C:\git\xxxx\regression\args-local.txt' '--pythonpath'
'c:\git\xxxx\regression\common\lib' '--variable'
'EXECDIR:C:/git/xxxx/regression'
'--prerunmodifier=robotframework_debug_adapter.prerun_modifiers.FilteringTestsSuiteVisitor'
'c:\git\xxxx\regression\api\api_Test.robot'
[ ERROR ] Parsing'--pythonpath' failed: File or directory to execute does not exist.
However, the test starts if I remove the argumentfile parameter but it, of course, fails because its missing arguments from the file.
Do note that the folder specified in pythopath exists and has some python libraries needed for the tests.

Getting errors while trying to build istio source on mac

I'm a newbie in Istio and I’m trying to build the Istio source locally in mac but somehow when I run "make build" I get the following errors.
...
Downloading envoy: https://storage.googleapis.com/istio-build/proxy/envoy-alpha-74393cf764c167b545f32eb895314e624186e5b6.tar.gz to
real 0m5.288s
user 0m0.707s
sys 0m0.685s
cp: cannot create regular file '': No such file or directory
Unexpected failure
make[1]: *** [Makefile.core.mk:230: /work/out/darwin_amd64/istio_is_init] Error 1
...
These are the following env variables that I have set.
export HUB="docker.io/shriramsharma"
export TAG="shriramsharma"
export GOOS=darwin
export USE_LOCAL_PROXY=1
export BUILD_WITH_CONTAINER=1
Is there something I’m missing? any help would be appreciated
Version: I ran make build on the master branch of the source. I did not checkout any release version tag.
Docs: I followed the steps in the docs here. https://github.com/istio/istio/wiki/Preparing-for-Development-Mac

On Visual Studio Code, how do I specify my pytest.ini file for test discovery

I use pytest for testing. My test files reside in a subdirectory tests and they are named Foo.py, Bar.py instead of test_Foo.py, TestFoo.py, etc. So, to make sure pytest find them, I have a pytest.ini file in the root dir of the project with the following contents:
[pytest]
python_files=tests/*py
How to I specify the path to the pytest.ini file in Visual Studio Code so that the vscode-python plugin can correctly/successfully discover my test files? No matter what I try, I get Test discovery failed, with no reasons given.
To set up VS Code to use a specific pytest.ini file, you need to do the following:
Open a directory in VS Code (ctrl+k > ctrl+o)
Select a Python interpreter (ctrl+shift+p > Python: Select Interpreter > Python interpreter)
Configure the testing framework you want to use, in this case PyTest (ctrl+shift+p > Python: Configure Tests > Pytest > {pytest rootdir}
Open the settings.json file generated inside the .vscode/ directory that was created in your working directory (the one you chose in step 1)
Add the following setting to the file (it may already exist if you specified a rootdir when configuring pytest):
"python.testing.pytestArgs": [
"-c",
"/path/to/your/pytest.ini"
],
That's it! VS Code should be using the pytest.ini file you specify in the last argument. You can specify any CLI options you want there.
Source
Pytest requires the test function names to start with test or ends with test.
The ini file instructs py.test to treat all *_test.py files as unit tests.

How can we run Robot Framework files and Test cases using command line?

Please can anyone suggest and help how can we execute the Robot Framework Test Cases and Files via command line ?
My Robot Framework Directory Location is as follows :
/Users/tanyagrover/Desktop/Robot Files/Charcoal PreProd
I've tried :
robot -L debug Charcoal preprod.robot
and got error as :
File "/usr/local/bin/robot", line 6, in <module>
from robot.run import run_cli
ModuleNotFoundError: No module named 'robot'
I'am using ride.py to create my test cases and the test cases are running fine when i'm using RIDE UI. But I want to run my test cases using Robot CLI. Whenever I'am executing my .robot file using robot command I'am getting following error
robot Login.robot
Traceback (most recent call last):
File "/usr/local/bin/robot", line 6, in
from robot.run import run_cli
ModuleNotFoundError: No module named 'robot'
Thank You
The reason you are getting the below error is , you need to go to the same virtualenv/interpreter where you have installed robotframework,as you have configured your eclipse to run on. Otherwise, you will get the below error.
File "/usr/local/bin/robot", line 6, in <module>
from robot.run import run_cli
ModuleNotFoundError: No module named 'robot'
Steps to remedy
You need to use the same virtualenv/interpreter and
then make sure you have robotframework installed and
then you need to invoke robot, only then it is going to work.
APPROACH#0
Assuming that you have created a virtualenv/interpreter with robotframework installed successfully, then you need to just
cd to that specific directory and
then execute robot as mentioned below.
If you want to run all the testcases from all the files and folders under Prepod
cd /Users/tanyagrover/Desktop/Robot\ Files/Charcoal\ PreProd
robot *.robot
NOTE: few users are confused regarding "cd" when dir name contains
space i have created a simple folder name "sample sd"(there is a space
in the folder name)
On mac this works,
cd sample\ sd/
06:30 PM##~/sample sd::>
First, make sure you have robot framework installed and it is found in PYTHONPATH environment variable.
For executing the tests, there are many ways to do this.
Option #1:
Go to Charcoal PreProd folder and just robot Suites
Option #2:
Go to Suites folder and just robot .
Option #3:
If you wanna run only Login test suite, in Charcoal PreProd folder: robot Login.robot (assuming the file extension for Login file is robot).
Also note that the last argument cannot have spaces as you have in Charcoal preprod.robot. In this case, you should use quotes: 'Charcoal preprod.robot'.
Setting default python version to 3.6 worked for me

How to build Conda env on Mac using Windows yml file?

I'm creating Conda create environment from yml I generated on Windows' Miniconda install. I need to create same environment on OS X. Following the advise found here on SO I used the --no-builds option.
Also, the names of some packages under section ResolvePackageNotFound are clearly (many if not all) specific to Windows:
- m2w64-gmp=6.1.0
- m2w64-gcc-libs-core=5.3.0
- m2w64-gcc-libs=5.3.0
- vc=14.1
- vs2015_runtime=15.5.2
- msys2-conda-epoch=20160418
- menuinst=1.4.14
- icc_rt=2019.0.0
- m2w64-libwinpthread-git=5.0.0.4634.697f757
- pywinpty=0.5.5
- wincertstore=0.2
- m2w64-gcc-libgfortran=5.3.0
- win_inet_pton=1.1.0
- winpty=0.4.3
I removed all of these from the yml file. Even then it's stalled at the following screen:
(base) MacBook-Air:Anaconda.d xtian$ conda env create -f 32b-qb-2019-10-05.yml
Collecting package metadata (repodata.json): done
Solving environment: \
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abor|
Examining openssl: 10%|█████████▍ | 29/279 [00:00<00:00, 3729.87it- ]
Comparing specs that have this dependency: 16%|██████████▉ | 16/101 [05:53<31:19, 22.11s/it]
Finding shortest conflict path for openssl[version='>=1.0.2p,<1.0.3a']: 38%|███████████████▊ | 6/16 [02:39<06:23, 38.32s/it]
This process is progressing at an astonishingly slow pace, and hasn't got past openssl ... 29/279. Should I wait and trust Conda can figure this all out?
Or,
Do I need another strategy--
I'm wondering if I can't remove the offending packages, each in turn, and create a series of yml files to install in order using, $ conda env update --prefix ./env --file environment.yml --prune, because whatever finally works here I know I'm going to need to use it on another machine so I can share the project env with a colleague.
Any other suggestions?
Short answer: Try deleting the packages that your system is getting stuck on from the .yml file. i.e., remove "openssl" from .yml file.
I have been running into the same issue trying to install a .yml file created in a Windows system to a Mac system. I basically followed the same procedure you did:
-Created yml file using the --no-builds option.
-Attempted to create environment on Mac system and had several windows specific packages left under ResolvePackageNotFound section (listed below)
m2w64-libwinpthread-git=5.0.0.4634.697f757
pyreadline=2.1
pywinpty=0.5.5
m2w64-gcc-libgfortran=5.3.0
vc=14
m2w64-gcc-libs-core=5.3.0
m2w64-gmp=6.1.0
wincertstore=0.2
icc_rt=2019.0.0
m2w64-gcc-libs=5.3.0
vs2015_runtime=14.15.26706
winpty=0.4.3
msys2-conda-epoch=20160418
-Deleted those from the yml file
-Attempted to create environment from updated yml file and received the following conflicts:
- Found conflicts! Looking for incompatible packages.
My system also got stuck trying to solve the "openssl" conflict along with a "_tflow_select". I ended up deleting those and was able to create my environment and run the code without too much trouble.