硒webdriver send_keys()不能正常工作 [英] Selenium webdriver send_keys() not working properly

查看:156
本文介绍了硒webdriver send_keys()不能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用selenium web驱动程序来自动执行Python脚本中的前端Web UI操作。在这方面,对于文本字段(必填字段)的输入值,使用 driver.find_element_by_xpath(< xpath>).send_keys(<值>)< c $ c> / p>

尽管我能够看到在相关文本字段中输入了值,但是在UI中抛出了一个说明文本框不能为空的错误消息。 >

浏览器:23.0(也可以使用旧版本,如20.0,16.0,它重现相同的问题)
Python版本:2.7

这是我的代码:

  sel = webdriver.Firefox()
sel.find_element_by_xpath(//输入[@ name ='minBid'])'。send_keys(2)
sel.find_element_by_xpath(// div [text()='Save'])

在运行此代码段时,不提供 min出价的UI投诉

请帮助解决这个挑战。谢谢。

解决方案

尝试在输入前点击该字段;

<$点击
sel.find_element_by_xpath(//输入[@ name ='minBid' send_keys(2)


I am using selenium web driver to automate front end web UI actions in Python script. In this regard to input value to a text filed (mandatory field), driver.find_element_by_xpath(<xpath>).send_keys(<value>) code is used.

Though I am able to see that value has been typed in the concerned text field, an error message saying text box cannot be empty is being thrown on the UI.

Browser : 23.0 (Also tried with old version like 20.0, 16.0 which reproduces same issue) Python Version : 2.7

Here is my code:

sel = webdriver.Firefox()
sel.find_element_by_xpath("//input[@name='minBid']")'.send_keys("2") 
sel.find_element_by_xpath("//div[text()='Save']")

Upon running this snippet, UI complaints saying min bid is not supplied.

Please help solve this challenge. Thank you.

解决方案

Try clicking on the field before input;

sel.find_element_by_xpath("//input[@name='minBid']")'.click
sel.find_element_by_xpath("//input[@name='minBid']")'.send_keys("2") 

这篇关于硒webdriver send_keys()不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆