名字我嘗試遠程登錄到Twitter和使用硒和鉻webdriver的鳴叫發現Twitter的元素,但我似乎無法得到它之前,我做任何事情我想只測試是否我可以寫入用戶名和密碼區域,但我甚至不能這樣做。不能使用硒和鉻的webdriver
這裏是我的代碼:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("https://twitter.com")
elem = driver.find_element_by_name("session[username_or_email]")
elem.send_keys("test")
elem.send_keys(Keys.RETURN)
當我嘗試這一點,打開命令提示符下運行chromedriver.exe然後打開鉻窗口,但再沒有什麼事情發生,這讓我這個錯誤消息:
Traceback (most recent call last):
File "C:\Python27\Project\Auth2.py", line 10, in <module>
elem.send_keys("test")
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 162, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': typing})
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 228, in _execute
return self._parent.execute(command, params)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 165, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 152, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchWindowException: Message: u'no such window: target window already closed\nfrom unknown error: web view not found\n (Session info: chrome=26.0.1410.64)\n (Driver info: chromedriver=0.8,platform=Windows NT 5.1 SP3 x86)'
誰能告訴我什麼是問題,以及如何解決它!
我得到它的工作我想我只是需要使用'driver.find_element_by_id',而不是'driver.find_element_by_name'和它的工作就好了! – Serial 2013-05-05 22:35:14
但現在我想知道如果我可以做到這一點出窗口彈出? – Serial 2013-05-05 22:38:20