51Testing软件测试论坛

标题: python+selenium ie下无法定位元素 [打印本页]

作者: wxc19881003    时间: 2015-1-16 16:19
标题: python+selenium ie下无法定位元素
selenium与iedriverserver的版本都是2.44
代码如下:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Ie()
#driver = webdriver.Firefox()
driver.get("http://www.baidu.com")
driver.implicitly_wait(5)
elem = driver.find_element_by_id("kw")
print elem
driver.close()
driver.quit()


IE浏览器能成功启动,但是无法找到kw元素,系统是win8.1,ie11
报错如下:
Traceback (most recent call last):
  File "E:/AutoTest/test.py", line 7, in <module>
    elem = driver.find_element_by_id("kw")
  File "D:\AutoTest\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 206, in find_element_by_id
    return self.find_element(by=By.ID, value=id_)
  File "D:\AutoTest\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 662, in find_element
    {'using': by, 'value': value})['value']
  File "D:\AutoTest\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 173, in execute
    self.error_handler.check_response(response)
  File "D:\AutoTest\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
    raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: Unable to find element with id == kw

望哪位大侠指点下啊

作者: wxc19881003    时间: 2015-1-16 16:42
在火狐下是可以正常运行的
作者: 新手上路~~~    时间: 2016-9-25 20:47
你搞定了么?可以共享下怎么解决么?
作者: zgj2008    时间: 2016-9-26 16:34
我的火狐打开后直接报错了




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2