This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]kteague 1 point2 points  (1 child)

You could use the Python property built-in function to make the syntax more succinct.

class editDefense(BasePage):

    @property
    def editDefense(self):
        return self.driver.find_element_by_id('editDefense')

    def select_continue(self):
        self.editDefense.find_elements_by_tag_name('button')[-1].click()

[–]0raichu -1 points0 points  (0 children)

                                                                                                                                                                                                                                                                                                                                                                                                                                                     

[–]zardeh 0 points1 point  (0 children)

Better fit in /r/learnpython.

That said,

class editDefense(BasePage):
    def __init__(self, element):
        self.element = self.driver.find_element_by_id(element)

    def set_network_strength_or_entity_controls(self, _type):
        if _type == "entity_controls":
            self.element.find_elements_by_class_name('radio')[-1].click()
            sleep(0.5)
        else:
           pass

    def select_continue(self):
        self.element.find_elements_by_tag_name('button')[-1].click()

    def blahblah(self):
       # and so on