0
我已经使用下面的代码使用xpath选择器。但它不起作用。请引导我知道这个问题的人以及我在这个代码中犯了错误的地方。链接文本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()
`
感谢您的回答。 –