0
PagnationButtons = []

class Xpather:
    def __init__(self,Xpath):
        self.Xpath = Xpath
        self.object = driver.find_elements(By.XPATH,Xpath)
        
    def Wait(self):
        return Wait60s.until(EC.presence_of_all_elements_located((By.XPATH,self.Xpath)))

class PagElement:
    def __init__(self,element):
        self.element = element
        self.index = self.Checkpags()
        
    def Checkpags():
        if PagnationButtons != []:
            ElementIndex = PagnationButtons[-1].index;
            return ElementIndex + 1
        else:
            return 1
        

Hello i am trying to make a variable that gives its self an index bassed on the last index of an array. It gives this error:

TypeError: PagElement.Checkpags() takes 0 positional arguments but 1 was given

I searched the error but the answers did not give me a solution that worked.

I made an if statement that if the array isnt empty it gives an index bassed on the last array element

What am i doing wrong?

  • Any class function must take at least one argument. By convention, we call it `self`. So change `def Checkpags():` to `def Checkpags(self):`. – Code-Apprentice Mar 29 '23 at 03:35
  • Also, I recommend that you read about naming conventions. In Python, function names should start with lower case. If the function name is multiple words, each word (other than the first) should start with upper case. – Code-Apprentice Mar 29 '23 at 03:36
  • could you put this as answer to help our bothers and sisters –  Mar 29 '23 at 03:39
  • The answer is already in the links at the top of your qeustion. – Code-Apprentice Mar 29 '23 at 17:03

0 Answers0