我正在尝试从我的python脚本在页面上的表单字段中发送数据,这些数据在http-server上运行。但是当我尝试使用PhantomJS驱动程序运行我的脚本时,我总是收到错误:
Unable to find element with id "x"
即使我在控制台中看到我的脚本已成功加载(绿灯)。但是当我使用Chrome驱动程序时,一切都很好。我被试了
wait.until(EC.presence_of_element_located((By.ID, "RCPN")))
但是这给了我timeoutexception错误。我目前的代码:
from random_data_generator import RandomDataGenerator
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.PhantomJS(
executable_path='c:\phantomjs\\bin\phantomjs.exe')
driver.get('http://someurl')
wait = WebDriverWait(driver, 5)
wait.until(EC.presence_of_element_located((By.ID, "blanks")))
driver.set_window_size(1024, 768) # optional
recipient = RandomDataGenerator()
sender = RandomDataGenerator()
driver.save_screenshot('screen.png') # save a screenshot to disk
rcpn_name = driver.find_element_by_id('RCPN')
rcpn.send_keys(recipient.get_name())
print rcpn_name
可能是什么问题?