本文整理匯總了Python中selenium.webdriver.PhantomJS.find_element方法的典型用法代碼示例。如果您正苦於以下問題:Python PhantomJS.find_element方法的具體用法?Python PhantomJS.find_element怎麽用?Python PhantomJS.find_element使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類selenium.webdriver.PhantomJS
的用法示例。
在下文中一共展示了PhantomJS.find_element方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: SeleniumTestCase
# 需要導入模塊: from selenium.webdriver import PhantomJS [as 別名]
# 或者: from selenium.webdriver.PhantomJS import find_element [as 別名]
class SeleniumTestCase(LiveServerTestCase):
def _pre_setup(self):
super(SeleniumTestCase, self)._pre_setup()
self.driver = PhantomJS()
def _post_teardown(self):
self.driver.quit()
super(SeleniumTestCase, self)._post_teardown()
def login(self, username='user', password='password', url='login'):
"""
Login to the server and be authenticated
"""
self.open(reverse(url))
self.driver.find_element_by_id("id_username").clear()
self.driver.find_element_by_id("id_username").send_keys(username)
self.driver.find_element_by_id("id_password").clear()
self.driver.find_element_by_id("id_password").send_keys(password)
self.driver.find_element_by_id("submit-id-login").click()
def open(self, url):
self.driver.get("%s%s" %(self.live_server_url, url))
def is_element_present(self, how, what):
try:
self.driver.find_element(by=how, value=what)
except NoSuchElementException, e:
return False
return True