码迷,mamicode.com
首页 > Web开发 > 详细

使用`selenium-webdriver-webelement.send_keys`遇到的问题

时间:2018-01-26 14:05:12      阅读:676      评论:0      收藏:0      [点我收藏+]

标签:pandas   play   value   height   white   class   blog   frame   element   

使用selenium-webdriver-webelement.send_keys遇到的问题

读取一个网页输入框,从 pandas 读取的 DataFrame 中取出一串数字输入进去。code:

for i in DF.iloc[:,11]:
    ele = browser.find_element_by_xpath("div[1]/div[2]/div/input")
    ele.clear()
    ele.send_keys(i)

遇到如下问题:

  File "d:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 351, in send_keys
    {‘text‘: "".join(keys_to_typing(value)),

  File "d:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\common\utils.py", line 150, in keys_to_typing
    for i in range(len(val)):

TypeError: object of type ‘numpy.int64‘ has no len()

因为 pandas 是以 numpy 为基础的,从DF读取的一串数字自然是numpy.int64类型的。因此将ele.send_keys(i)改为ele.send_keys(int(i))即可。

?

使用`selenium-webdriver-webelement.send_keys`遇到的问题

标签:pandas   play   value   height   white   class   blog   frame   element   

原文地址:https://www.cnblogs.com/aubucuo/p/selenium180126.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!