Robot Framework - Running on diffrent devices file - robotframework

This is a follow up on my previous question - [RobotFramework - Run Tests on different environments
I Have created a file for each of the environments, this is all working, right now I am just using My local tablet to test, I need to point to 10 different devices with different settings, Is there a way to store the configuration dynamically in the arguments file? Like get the configuration using robot store it in a variable and use that value in the arguments file?
Something like
//HERE sample code the get the androidVersion = ${Get_Android_Version}
.args file
--variable REMOTE_URL_ANDROID:http://127.0.0.1:4723/wd/hub
--variable PLATFORM_NAME_ANDROID:Android
--variable PLATFORM_VERSION_ANDROID:${Get_Android_Version}
--variable DEVICE_NAME_ANDROID:Samsung
--variable AUTOMATION_Name_ANDROID:appium
--variable PACKAGE_NAME_ANDROID:DiffrentPackage
--variable ACTIVITY_NAME_ANDROID:PackageName
Ps. I know its not real robot code its just a sample of what i mean.

You cannot have any programming logic in an argument file. Instead of (or in addition to) using an argument file for this, you might want to consider a variable file. Variable files are python code, so you can do any kind of logic you need in order to set your variables.
For example, you could pass the name of the environment from the command line, and use that in your test to import the variables for that environment.
Example
test.robot:
*** Settings ***
Variables ${ENVIRONMENT}_vars.py
...
smoke_vars.py:
def get_platform_version(platform):
<your logic here>
return $version
PLATFORM_NAME = "Android"
PLATFORM_VERSION = get_platform_version(PLATFORM_NAME)
command line:
robot --variable environment:smoke test.robot
You can also specify the variable file on the command line instead of in the test file. For example, you could remove the Variables setting and then do this on the command line:
robot --variablefile smoke_vars.py ...
All of this is very thoroughly documented in the robot framework user guide

Related

Meson custom_target never executes despite sources and dependencies out of date

I've got this section in my project's root's meson.build:
if get_option('gen_py_bindings')
message('told to build py bindings')
custom_target('py_bindings',
command: ['env', '_MESON_MODULE_NAME=' + meson.project_name(), ',_MESON_MODULE_VERSION=' + meson.project_version(), './py3_bindings/setup.py', 'build'],
depends: [mainlib],
depend_files: files(['py3_bindings/module.c', 'py3_bindings/setup.py']),
input: ['py3_bindings/setup.py'],
install: false, output: 'sharedextension.so')
endif
It's a custom target that runs a setup.py script to build python bindings for my project's library.
The problem is that it is always seemingly up-to-date. I've used the depends keyword argument to specify that it depends on another build target in the project, and the depend_files keyword argument to specify that it depends on the C source file that the script uses to build the extension, as well the actual script that is being ran as the command. I've also used the input keyword argument even though I don't understand the difference between it and depend_files.
I can only get the custom target to regenerate if I make a change to meson.build (the message() call is displayed successfully).
No other change will do. I've tried updating all files listed in the custom target but it always results in: ninja: no work to do.. Even if other out-of-date targets get rebuilt/relinked/etc...
I'm using ninja 1.9.0 and meson 0.52.1 on linux.
I am also well aware of the build_always_stale keyword argument but I don't want to use it unless necessary. (update: setting it to true still doesn't result in the target rebuilding, looks like there's something more at play here but I can't figure it out).
By default, custom targets don't get built when running plain ninja and thus the build_by_default keyword argument needs to be passed and set to true, e.g.
custom_target('target', build_by_default: true)

How can I use built-in variables in the variable file in Robot Framework [duplicate]

I have some settings-type global vars that I'd like to be able to access from Python code. For example:
pybot --variable RESULTS_PATH:/wherever/this/points test.txt
Now, my module logger.py file needs to know the results_path to set up properly.
I know that I can initialize the logger with a variable, like
***Settings***
Library logger ${RESULTS_PATH}
And then in logger I'll be passed results_path:
def __init__(self, results_path):
# Whatever
However the problem with doing it this way for me is that I want to access and use the logger from both Python code and within test cases. So if I set it up this way, if I want to use the logger from Python code I run into the same problem of needing results_path to initialize the logger properly.
Are there any functions in the robot framework library that would allow me to grab the value of ${RESULTS_PATH} from Python code? What is the proper way to do something like this?
Right now, my workaround for the issue is to set RESULTS_PATH as an environment variable. So I have something like:
Run like:
RESULTS_PATH=/wherever/this/points pybot test.txt
File test.txt:
***Settings***
Library logger
...
File logger.py:
results_path = os.environ["RESULTS_PATH"]
# Other set up stuff
You will want to use rf's BuiltIn library, for reference read the documentation as found here. This provides the keywords that are built into Robot Framework and so should reliably stay usable:
from robot.libraries.BuiltIn import BuiltIn
results_path = BuiltIn().get_variable_value("${RESULTS_PATH}")

why cppcheck report have no function name?

I can set report format like "./cppcheck --template {file}:{line},{severity},{id},{message}" to get more information, but can not get function name.
Is there any method?

Google closure variable window/event/console/... is undeclared error

I'm trying to compile one of my HTML5 project using Google Closure. I'm recieving several errors that I don't know how to solve. In fact, it's the same error but for different variables.
Here the errors messages:
variable window is undeclared
variable event is undeclared
variable console is undeclared
variable Audio is undeclared
These variables are Javascript built-in variables. If I compile this same project directly in command-line, it works. But, in my case, I need to compile this project using an ant file (build process). My ant build script is using the same jar file that I use in command-line. With the option warnings="verbose", it doesn't work. If I remove it, it works. If I would like to use the option warnings-"verbose", what I have to do? Please explain me the difference.
Could somebody help me please?
Thank you!
The option --warnings=verbose sets the compiler to "ninja mode"; i.e. every single variable in your file should be declared (an annotated!) correctly. For example, the window variable is unknown to the compiler, but Closure has an implementation of window (independent of the platform used). If your variables are included in some other file, use externs. If yo still want to use Verbose mode without the 'undeclared variable' error, use the flag --jscomp_off=checkVars

How do I initialize variables used for importing libraries in Ride?

I have a custom robot framework library which accepts an argument to initialize it.
*** Settings ***
Library NotifyUsers ${max_messages}
This works just fine when executed from the command line using pybot:
pybot --variable max_messages:4 my_test
However, this variable doesn't exist in Ride when it imports the library at startup. I've tried defining it in the Arguments field on the Run tab, but that isn't instantiated until you run a test.
If I replace the variable and hard code an integer argument, it works fine in Ride.
Apologies to Bryan Oakley! I somehow managed to delete his answer which pointed me in the right direction.
Adding an entry to the variable table does not resolve this issue, however using a Variable File does! It appears that Ride will import variable files when it starts up. Variable Tables contained in a test suite are not resolved until run time.

Resources