HyperRobotFrameworkPlugin
HyperRobotFrameworkPlugin copied to clipboard
Class variables not recognized and don't autofill
Variables that are defined in a class aren't recognized or autofilled when writing test cases in robot. I created multiple files with various classes to organize my locator variables but they are all unrecognized in robot files. Everything runs fine and tests pass, its just much harder to write and figure if a variable actually does not exist.
Test.robot:
Testing
[Documentation] Testing Stuff
Open Test Application
Tap Element ${WelcomeScreen.iAgree_button}
Tap Element ${LetsGetStartedScreen.setupNow_button}
Locators.py:
class WelcomeScreen:
EULAPrivacy_link = "//android.view.ViewGroup/android.widget.TextView[2]"
iAgree_button = "IAgreeButton"
debugSettings_button = "//android.view.ViewGroup/android.view.ViewGroup/android.widget.ImageButton"
class LetsGetStartedScreen:
setupNow_button = "SetupButton"
tutorial_button = "TutorialButton"
In this case ${WelcomeScreen.iAgree_button} and ${LetsGetStartedScreen.setupNow_button} won't autofill and display an unknown variable in the editor.
For now, plugin does not support variable parsing with syntax like ${class_name.var_name}, the workaround is:
from dataclasses import dataclass, asdict
@dataclass
class Foo:
foo_int_var: int = 1
foo_str_var: str = "1"
@dataclass
class Bar:
bar_int_var: int = 1
bar_str_var: str = "1"
def get_variables():
return {**asdict(Foo()), **asdict(Bar())}
then you can use the variable by name directly, but the limitation is this will be conflict if there're same name var in different var class.