mylaoxiaoxiao
mylaoxiaoxiao
2017-05-05 03:56

【求助】为何我这个元素定位不到呢

  • python
  • 自动化测试
  • selenium

#coding=utf-8
from selenium import webdriver
import time
driver = webdriver.Firefox()

driver.set_window_size(480,800) 设置浏览器大小

driver.get("http://10.188.181.74:9082/sso-webapp")
driver.maximize_window()
#登录系统
driver.find_element_by_name('username').clear()
driver.find_element_by_name('username').send_keys('zhulj')
driver.find_element_by_name('psword').clear()
driver.find_element_by_name('psword').send_keys('1')
driver.find_element_by_name('submitBtn').click()
time.sleep(30)
#进入需求填报销单,需求填报单为新弹开页面
driver.find_element_by_xpath("/html/body/div/div/div[2]/div[3]/div/a[2]/div/div/p[2]").click()
time.sleep(20)
#就是下面这个定位不到了
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[3]/div/div[2]/ul/li[6]/a").click()


报错如下:
C:\Users\sunl\AppData\Local\Programs\Python\Python36\python.exe E:/自动化测试/test/登录客反.py
Traceback (most recent call last):
File "E:/自动化测试/test/登录客反.py", line 26, in
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[3]/div/div[2]/ul/li[6]/a").click() #就这句了
File "C:\Users\sunl\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 306, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\sunl\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 784, in find_element
'value': value})['value']
File "C:\Users\sunl\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 249, in execute
self.error_handler.check_response(response)
File "C:\Users\sunl\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: /html/body/div[1]/div[1]/div[3]/div/div[2]/ul/li[6]/a

firebug贴图如下 :
图片说明

看了下这个元素并没有在frame和iframe

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐