我使用 xpath 选择器使用了下面的代码。但它不工作。请指导我谁知道这个问题以及我在这个代码中犯了错误的地方。
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
class CGBrowseJobs(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://www.ionface.com/"
self.verificationErrors = []
def test_c_g_browse_jobs(self):
driver = self.driver
driver.get(self.base_url + "/")
driver.find_element_by_link_text("Career Grab").click()
driver.find_element_by_xpath("//a[text()='Browse Jobs']/@href").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()
`