我是Python和Selenium的新手。你能解释一下driver.title参数是如何导出的吗?下面是一个简单的webdriver脚本。 如何找到与various asserts in the unittest module一起使用的其他driver.x参数?
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class PythonOrgSearch(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
def test_search_in_python_org(self):
driver = self.driver
driver.get("http://www.python.org")
self.assertIn("Python", driver.title)
elem = driver.find_element_by_name("q")
elem.send_keys("selenium")
elem.send_keys(Keys.RETURN)
self.assertIn("Google", driver.title)
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()
答案 0 :(得分:21)
我不确定你在这里问的是什么。
其他driver.x参数可在documentation或source code中找到。
# Generally I found the following might be useful for verifying the page:
driver.current_url
driver.title
# The following might be useful for verifying the driver instance:
driver.name
driver.orientation
driver.page_source
driver.window_handles
driver.current_window_handle
driver.desired_capabilities