15387968462 发表于 2016-5-20 13:25:57

python+selenium 脚本运行时,在Firefox浏览器正常,但是在IE时(倒数第三行)ID定位报错

#coding=utf-8
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import login1,quit1,time

driver = webdriver.Ie()
driver.get('https://mail.qq.com/cgi-bin/loginpage')
driver.maximize_window()
title = driver.title
print title
now_url = driver.current_url
print now_url

#time.sleep(5)
#调用登录
login1.login(driver)
title = driver.title
print title
now_url = driver.current_url
print now_url
#进入附件收藏
element = WebDriverWait(driver,5,0.5).until(
        EC.presence_of_element_located((By.ID,"folder_attach_td"))
        )
element.click()

15387968462 发表于 2016-5-20 13:31:02

跟浏览器兼容应该没关系吧

若尘_51 发表于 2016-5-20 14:06:19

你问题也不描述清楚点,怎么帮,起码附个截图什么的,报错信息。

你是我的好时光 发表于 2016-5-20 14:36:10

你问题也不描述清楚点,怎么帮,起码附个截图什么的,报错信息。

15387968462 发表于 2016-5-20 14:43:50

你是我的好时光 发表于 2016-5-20 14:36
你问题也不描述清楚点,怎么帮,起码附个截图什么的,报错信息。

登录QQ邮箱
https://mail.qq.com/cgi-bin/loginpage
Traceback (most recent call last):
File "C:\Users\lidiya\Desktop\text.py\test.py", line 25, in <module>
    EC.presence_of_element_located((By.ID,"folder_attach_td"))
File "C:\Python27\lib\site-packages\selenium\webdriver\support\wait.py", line 71, in until
    value = method(self._driver)
File "C:\Python27\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 59, in __call__

15387968462 发表于 2016-5-20 14:43:59

登录QQ邮箱
https://mail.qq.com/cgi-bin/loginpage
Traceback (most recent call last):
File "C:\Users\lidiya\Desktop\text.py\test.py", line 25, in <module>
    EC.presence_of_element_located((By.ID,"folder_attach_td"))
File "C:\Python27\lib\site-packages\selenium\webdriver\support\wait.py", line 71, in until
    value = method(self._driver)
File "C:\Python27\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 59, in __call__

掉渣饼 发表于 2016-5-20 21:51:43

15387968462 发表于 2016-5-20 14:43
登录QQ邮箱
https://mail.qq.com/cgi-bin/loginpage
Traceback (most recent call last):


EC.presence_of_element_located((By.ID,"folder_attach_id"))
替换成
EC.presence_of_element_located((By.ID,"folder_attach"))
应该就可以了,你找的元素ID不准确
页: [1]
查看完整版本: python+selenium 脚本运行时,在Firefox浏览器正常,但是在IE时(倒数第三行)ID定位报错