I need to have a decorator that takes an argument and checks (based on some simple logic) if the method should be allowed to run or raise an exception.
class One(obj):
trend = "trend"
@myDecorator(self.trend)
def click_button(self):
clickable_element = self.driver.find_element_by_id(self.trend)
clickable_element.click()
return self
class Two(obj):
map = "map"
@myDecorator(self.map)
def click_button(self):
clickable_element = self.driver.find_element_by_id(self.map)
clickable_element.click()
return self
The logic should be something like this:
def my Decorator(arg):
if arg:
"run the method"
else:
raise "Exception"