Python 使用Internet Explorer发送密钥时发生错误,以前的评估尚未完成

Python 使用Internet Explorer发送密钥时发生错误,以前的评估尚未完成,python,python-2.7,unit-testing,selenium,Python,Python 2.7,Unit Testing,Selenium,我使用的是Python 2.7,selenium是3.4.3: search_field= self.driver.find_element(By.ID ,'Searchbox') time.sleep(10) search_field.send_keys('test' + Keys.RETURN) 它在Chrome和Firefox中工作,但在IE中使用时不起作用: search_field.send_keys('test' + Keys.RETURN) 它将返回错误,如下所示: pre

我使用的是Python 2.7,selenium是3.4.3:

search_field= self.driver.find_element(By.ID ,'Searchbox')  
time.sleep(10)
search_field.send_keys('test' + Keys.RETURN)
它在Chrome和Firefox中工作,但在IE中使用时不起作用:

search_field.send_keys('test' + Keys.RETURN)
它将返回错误,如下所示:

previous evaluation has not completed.
如何使发送密钥正常工作

添加Html

<div>
<input type="text" value="" id="Searchbox" name="name" class="input-xlarge search-query searchInput" style="padding:3px;" data-reactid=".0.1.0.0.0.1.0.0.1.0.0.1">
<span class="btn btn-small btn-warning" style="border-radius:0px;padding-left:3px;padding-right:3px;height:28px;margin-left:1px;" data-reactid=".0.1.0.0.0.1.0.0.1.0.0.2"><i class="icon-search icon-on-right bigger-110" data-reactid=".0.1.0.0.0.1.0.0.1.0.0.2.0"></i></span>
</div>

错误说明了一切:

previous evaluation has not completed
一个简单的解决方案是将复合语句分解为多个语句,如下所示:

search_field.send_keys("test")
search_field.send_keys(Keys.RETURN)

更新: 根据您在问题中更新的
HTML
,要在
标记中发送密钥,您可以使用以下代码行之一:

self.driver.find_element(By.XPATH ,"//input[@id='Searchbox']").send_keys("test")
#or
self.driver.find_element(By.XPATH ,"//input[@name='name']").send_keys("test") 
#or
self.driver.find_element(By.XPATH ,"//input[@class='input-xlarge search-query searchInput' and @id='Searchbox']").send_keys("test")

在您的案例中使用以下代码:

search_field = self.driver.find_element(By.ID ,'Searchbox')
time.sleep(10)
search_field.send_keys('test')

search_button = self.driver.find_element(By.CSS_SELECTOR, '.btn.btn-small.btn-warning')
time.sleep(10)
search_button.click()
希望它能帮助你


顺便说一句,你可以使用显式或隐式等待来代替
时间。睡眠(10)

那么,你没有搜索按钮吗?是的,我有,但现在我只是无法在SearchBox上输入文本请添加你的HTML。@RatmirAsanov补充说你试过我的答案吗?进展如何?我已经尝试了搜索字段。发送密钥(“测试”),但错误消息相同使用您的代码试用更新问题,相关的HTMLerror Stack Trace。我已经添加了HTML,我没有更多的错误消息这是一样的,没有工作没有说明发生了什么。使用当前代码和错误堆栈跟踪更新问题。它已修复,我需要更多时间等待随机元素这是我的工作,我需要更多时间等待随机元素elements@ZivHus,如果我的答案有帮助,请在我的答案旁边打勾。