python+selenium 定位元素异常类型及解决方法
2017-04-06 17:22
811 查看
一、ElementNotVisibleException
[样例]
运行结果:抛出异常ElementNotVisibleException
[解决]
将
修改为:
element0=driver.find_element(By.LINK_TEXT, "登录")for ele0 in element0: if ele0.is_displayed(): ele0.click()
运行结果:TypeError: 'FirefoxWebElement' object is not iterable
[解决]
将
[样例]
from selenium import webdriver from selenium.webdriver.common.by import By driver = webdriver.Firefox() driver.implicitly_wait(10) driver.get("http://www.baidu.com")
driver.find_elements(By.LINK_TEXT, "登录").clcik()
运行结果:抛出异常ElementNotVisibleException
[解决]
将
driver.find_elements(By.LINK_TEXT, "登录").clcik()
修改为:
element0=driver.find_elements(By.LINK_TEXT, "登录") for ele0 in element0: if ele0.is_displayed(): ele0.click() 二、WebElement object is not iterable
[样例]
from selenium import webdriver from selenium.webdriver.common.by import By driver = webdriver.Firefox() driver.implicitly_wait(10) driver.get("http://www.baidu.com")
element0=driver.find_element(By.LINK_TEXT, "登录")for ele0 in element0: if ele0.is_displayed(): ele0.click()
运行结果:TypeError: 'FirefoxWebElement' object is not iterable
[解决]
将
element0=driver.find_element(By.LINK_TEXT, "登录")修改为:
element0=driver.find_elements(By.LINK_TEXT, "登录")
相关文章推荐
- Python使用Selenium测试WebApp在定位元素和使用元素属性报的莫名其妙错误的终极解决方法
- Python+Selenium xpath 定位遇到相同元素时的解决方法父节点找子节点
- [python爬虫] Selenium常见元素定位方法和操作的学习介绍
- Python中遍历字典过程中更改元素导致异常的解决方法
- selenium定位不到元素的几种情况和解决方法
- selenium+python 元素定位方法
- 【Python】Selenium元素定位错误之解决办法
- selenium+webdriver+python定位不到元素的原因及解决办法
- Python+Selenium定位不到元素常见原因及解决办法(报:NoSuchElementException)
- [python爬虫] Selenium常见元素定位方法和操作的学习介绍
- 【转】【selenium+Python WebDriver】之元素定位不到解决办法
- [python爬虫] Selenium常见元素定位方法和操作的学习介绍
- [python爬虫] Selenium常见元素定位方法和操作的学习介绍
- Python+Selenium的元素定位方法(xpath)
- Selenium常见元素定位方法和操作的学习介绍-python爬虫
- Python+Selenium定位不到元素常见原因及解决办法(报:NoSuchElementException)
- selenium(python)定位(查找)元素的方法小结
- Python中遍历字典过程中更改元素导致异常的解决方法
- selenium python (二) 元素定位方法
- Selenium定位页面元素的方法