Py学习  »  Python

如何使用python selenium脚本将数组发送到文本框?

naveen sai • 5 年前 • 1395 次点击  

我编写的用于将数组列表发送到内部站点中的文本框的代码。其中数组的输入来自excel。

value = [] // ArrayList
while len(value)<1000:
    Data=sheet.row(loop)
    T1 = Data[1].value
    T2=int(T1) // to remove float values
    T2 = str(T2) // as the text-box is only accepting the strings
    value.append(T2)
    loop += 1 //to read the next row in the excel sheet.
    driver.find_element_by_xpath('//*[@id="operand.action_(id=7)"]').send_keys(values[0:])

发送到文本框的值的格式为:['40554666','40554539','40554762','40554806']

这给了我一个错误,因为上面的代码以错误的格式将值发送到文本框,我需要删除“''”和“[%”文本框只能接受以逗号分隔的数字或新行中的数字。

注意:我试图一次发送一个元素,但这对我的网站不是有效的解决方案。这就是我一次发送1K值的原因。

有人能帮我一下吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/40166
 
1395 次点击  
文章 [ 1 ]  |  最新文章 5 年前