Search code examples
python-2.7seleniumpython-itertools

Selenium Send_keys expected 1 argument got 10000


I am trying to use Itertools product to produce a large list of characters and send them to the form one by one, testing each one to see if it throws an error or not.

I have ran into this problem and believe it is because of send_keys because I can print f and it will print each on a line but, send_keys will throw an error

result = []
redone = [''.join(i) for i in itertools.product(printable, repeat = 2)]
result.append(redone)
def dishack():
    for f in sorted(set(*redone)):
        discount.send_keys(f)
        driver.find_element_by_class_name('classname').click()
        time.sleep(5)
        try:
            disterror = driver.find_element_by_xpath('XPATH')   
            print 'Yes'
        except:
            print 'nope'

Here is the error I receive when running the code

for f in sorted(set(*redone)):
TypeError: set expected at most 1 arguments, got 10000

Please let me know if you have any suggestions to improve my code!


Solution

  • set() should accept the iterable object, so just pass the list instead of unpacking it:

    def dishack():
        for f in sorted(set(redone)):
            discount.send_keys(f)
            ....