How to use get_robot_aliases method in robotframework-pageobjects

Best Python code snippet using robotframework-pageobjects_python

page.py

Source:page.py Github

copy

Full Screen

...193 elif inspect.ismethod(obj) and not name.startswith("_") and not _Keywords.is_method_excluded(name):194 # Add all methods that don't start with an underscore and were not marked with the195 # @not_keyword decorator.196 if not in_ld:197 keywords += _Keywords.get_robot_aliases(name, self._underscore(self.name))198 else:199 keywords.append(name)200 _Keywords.has_registered_s2l_keywords = True201 return keywords202 def _attempt_screenshot(self):203 try:204 self.capture_page_screenshot()205 except Exception, e:206 if e.message.find("No browser is open") != -1:207 pass208 @not_keyword209 def run_keyword(self, alias, args, kwargs):210 """211 RF Dynamic API hook implementation that maps method aliases to their actual functions.212 :param alias: The alias to look up213 :type alias: str214 :param args: The arguments for the keyword215 :type args: list216 :returns: callable217 """218 # Translate back from Robot Framework alias to actual method219 meth = getattr(self, _Keywords.get_funcname_from_robot_alias(alias, self._underscore(self.name)))220 try:221 ret = meth(*args, **kwargs)222 except:223 # Pass up the stack, so we see complete stack trace in Robot trace logs224 raise225 if isinstance(ret, Page):226 # DCLT-829227 # In Context, we keep track of the currently executing page.228 # That way, when a keyword is run, Robot (specifically, our monkeypatch229 # of Robot's Namespace class - see context.py) will know which library230 # to run a keyword on when there is a conflict.231 # All page object methods should return an instance of Page.232 # Look at the class name of that instance and use it to identify233 # which page object to set Context's pointer to.234 # Get the names of all currently imported libraries235 libnames = Context.get_libraries()236 classname = ret.__class__.__name__237 for name in libnames:238 # If we find a match for the class name, set the pointer in Context.239 if name.split(".")[-1:][0] == classname:240 Context.set_current_page(name)241 # The case of raising an exception if a page object method returns None is handled242 # by Page's meta class, because we need to raise this exception for Robot and243 # outside Robot.244 # If nothing was returned and the method was defined in Selenium2Library,245 # just return self. That way, we exempt Selenium2Library from the "must_return"246 # requirement, but still know what page we're on. (For Selenium2Library keywords247 # that go to another page, we'll just assume we're using the same PO.)248 if ret is None:249 func = meth.__func__250 if meth in Selenium2Library.__dict__.values():251 ret = self252 else:253 for base in Selenium2Library.__bases__:254 if meth.__func__ in base.__dict__.values():255 ret = self256 break257 return ret258 @not_keyword259 def get_keyword_documentation(self, kwname):260 """261 RF Dynamic API hook implementation that exposes keyword documentation to the libdoc tool262 :param kwname: a keyword name263 :return: a documentation string for kwname264 """265 if kwname == '__intro__':266 docstring = self.__doc__ if self.__doc__ else ''267 s2l_link = """\n268 All keywords listed in the Selenium2Library documentation are also available in this Page Object.269 See http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html270 """271 return docstring + s2l_link272 kw = getattr(self, kwname, None)273 alias = ''274 if kwname in _Keywords._aliases:275 alias = '*Alias: %s*\n\n' % _Keywords.get_robot_aliases(kwname, self._underscore(self.name))[0].replace('_', ' ').title()276 docstring = kw.__doc__ if kw.__doc__ else ''277 docstring = re.sub(r'(wrapper)', r'*\1*', docstring, flags=re.I)278 return alias + docstring279 @not_keyword280 def get_keyword_arguments(self, kwname):281 """282 RF Dynamic API hook implementation that exposes keyword argspecs to the libdoc tool283 :param kwname: a keyword name284 :return: a list of strings describing the argspec285 """286 kw = getattr(self, kwname, None)287 if kw:288 args, varargs, keywords, defaults = inspect.getargspec(kw)289 defaults = dict(zip(args[-len(defaults):], defaults)) if defaults else {}...

Full Screen

Full Screen

snap.py

Source:snap.py Github

copy

Full Screen

...68 msg = ';'.join('{}'.format(get_pos(m))69 for m in rr.get_motors_list())70 return msg71 @self.app.get('/motors/alias')72 def get_robot_aliases():73 return '/'.join('{}'.format(alias) for alias in rr.get_motors_alias())74 @self.app.get('/motors/set/goto/<motors_position_duration>')75 def set_motors_goto(motors_position_duration):76 """ Allow lot of motors position settings with a single http request77 Be carefull: with lot of motors, it could overlap the GET max78 lentgh of your web browser79 """80 for m_settings in motors_position_duration.split(';'):81 settings = m_settings.split(':')82 rr.set_goto_position_for_motor(settings[0], float(settings[1]), float(settings[2]))83 return 'Done!'84 @self.app.get('/motors/set/registers/<motors_register_value>')85 def set_motors_registers(motors_register_value):86 """ Allow lot of motors register settings with a single http request...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run robotframework-pageobjects automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful