Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I need a help to know how can I can iterate a loop over a array which is in another function of the same class. I tried using the following similar code for automation in selenium and I get the following error.

class Test:
    def array_method1(self, product):
        self.product = product
        if product == "First":
           group1 = ['A','B','C']
        elif product == "Second":
           group2 = ['C','D','E']

     def iterate_product(self, product):
        self.product = product
        for test in self.array_method1(product):
            browser.find_element_by_name(test).click()

I called the function as iterate_product('First') and I got the error as

TypeError: 'NoneType' object is not iterable

Could someone help me on this.

share|improve this question
    
I found the problem why I was getting the error, it was due to the wrong parameters I was sending to the function in my program. –  Ranadheer Dec 12 '13 at 16:49

1 Answer 1

up vote 1 down vote accepted

Your code array_method1 above does not return anything hence it returns None so you can not iterate through it with the line:

for test in self.array_method1(product):

array_method1 needs to return like:

    self.product = product
    if product == "First":
       result = ['A','B','C']
    elif product == "Second":
       result = ['C','D','E']
    else:
       result = []
    return result
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.