I m new to selenium python. right now i m trying to run python code that already converted from selenium Ide. when i m ran the code i got this error. i m using eclipse to run the code
ERROR: test_isnin2 (__main__.Isnin2)
======================================================================
ERROR: test_isnin2 (__main__.Isnin2)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:EclipseWorkspacescsse120pythonsrcIsnin2.py", line 20, in test_isnin2
driver.get("/search?q=google&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a")
File "C:Program FilesPython27libsite-packagesselenium-2.4.0-py2.7.eggseleniumwebdriver
emotewebdriver.py", line 154, in get
self.execute(Command.GET, { url : url})
File "C:Program FilesPython27libsite-packagesselenium-2.4.0-py2.7.eggseleniumwebdriver
emotewebdriver.py", line 144, in execute
self.error_handler.check_response(response)
File "C:Program FilesPython27libsite-packagesselenium-2.4.0-py2.7.eggseleniumwebdriver
emoteerrorhandler.py", line 111, in check_response
zeroeth = value[ stackTrace ][0]
IndexError: list index out of range
----------------------------------------------------------------------
Ran 1 test in 35.406s
FAILED (errors=1)
我的发言如下:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
class Isnin2(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://www.google.com.my/"
self.verificationErrors = []
def test_isnin2(self):
driver = self.driver
driver.get("/search?q=google&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a")
driver.find_element_by_css_selector("em").click()
driver.find_element_by_id("lst-ib").click()
driver.find_element_by_id("lst-ib").clear()
driver.find_element_by_id("lst-ib").send_keys("selenium python")
driver.find_element_by_link_text("Setting Up Selenium with Python").click()
driver.find_element_by_link_text("selenium.py").click()
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException, e: return False
return True
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
i 真正希望有人能够帮助我,因为一滴新东西可以 se。