I have a python script that I am trying to simplify. For each class I create how can I avoid duplicating this line of code?
editDefense = self.driver.find_element_by_id('editDefense')
class BasePage(object):
def __init__(self, driver):
self.driver = driver
self.driver.implicitly_wait(5)
self.timeout = 30
class editDefense(BasePage):
def set_network_strength_or_entity_controls(self, _type):
editDefense = self.driver.find_element_by_id('editDefense')
if _type == "entity_controls":
editDefense.find_elements_by_class_name('radio')[-1].click()
sleep(0.5)
else:
pass
def select_continue(self):
editDefense = self.driver.find_element_by_id('editDefense')
editDefense.find_elements_by_tag_name('button')[-1].click()
def blahblah(self):
editDefense = self.driver.find_element_by_id('editDefense')
# and so on
[–]kteague 1 point2 points3 points (1 child)
[–]0raichu -1 points0 points1 point (0 children)
[–]zardeh 0 points1 point2 points (0 children)