Python 在文本框中输入文本时出现StopIteration错误

Python 在文本框中输入文本时出现StopIteration错误,python,selenium,exception,textbox,stopiteration,Python,Selenium,Exception,Textbox,Stopiteration,我正在尝试使用Python和Selenium将一个长字符串(大约4000个字符)输入到文本框中 输入完整字符串后,文本框中的全部内容将消失,并出现以下错误: 内部停止迭代:False c:\users\echo\anaconda3\lib\site packages\ipython\core\interactiveshell.py(3058)run\u cell\u async() ->交互性=交互性,编译器=编译器,结果=结果) 在调试模式下,我使用send_键(“aapl”)进行了测试,它工

我正在尝试使用Python和Selenium将一个长字符串(大约4000个字符)输入到文本框中

输入完整字符串后,文本框中的全部内容将消失,并出现以下错误:

内部停止迭代:False

c:\users\echo\anaconda3\lib\site packages\ipython\core\interactiveshell.py(3058)run\u cell\u async() ->交互性=交互性,编译器=编译器,结果=结果)

在调试模式下,我使用send_键(“aapl”)进行了测试,它工作得很好,但不能使用长字符串。循环也可以很好地工作,它提供了一个字符串,包含大约800个用逗号分隔的符号

我的代码:

# Get symbols from Excel

filename = "file path"
wb1 = xl.load_workbook(filename)
ws1 = wb1.worksheets[8]
mr = ws1.max_row
symbols = ""
for i in range(2, mr + 1):
        c = ws1.cell(row = i, column = 1)
        if isinstance(c.value, str):
            symbols += f",{c.value}"
        else:
            print(c)

# Input symbols to Watchlist

WebDriverWait(driver, 30).until(EC.visibility_of_element_located((By.XPATH, '//input[@data-ng-model="userEnteredSymbols"]'))).send_keys(symbols)

# The code for the website:

    <input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" placeholder="Add a symbol..." class="sec-search-box bc-form__add-symbol-input ng-pristine ng-invalid ng-invalid-required ng-touched placeholder" data-ng-model="userEnteredSymbols" data-barchart-clear-input="" required="">```
#从Excel中获取符号
filename=“文件路径”
wb1=xl.load\u工作簿(文件名)
ws1=wb1.工作表[8]
mr=ws1.max\u行
symbols=“”
对于范围(2,mr+1)内的i:
c=ws1.单元格(行=i,列=1)
如果存在(c.值,str):
符号+=f“,{c.value}”
其他:
印刷品(c)
#将符号输入监视列表
WebDriverWait(driver,30).until(EC.visibility_的_元素位于((By.XPATH,//input[@data ng model=“userenteredsymbles”]))。发送_键(符号)
#网站代码:
```

这样问题就解决了。我用了一个发电机,并通过它循环,不知道如何,但它现在的工作

def gen_function():
l = symbols
for s in l:
    yield s
gen_obj = gen_function()

# Input symbols to Watchlist
for s in gen_obj:
    WebDriverWait(driver, 30).until(EC.visibility_of_element_located((By.XPATH, '//input[@data-ng-model="userEnteredSymbols"]'))).send_keys(s)