I'm new to Python and Selenium. How is the driver.title parameter is derived? Below is a simple webdriver script. How do you find what other driver.x parameters there are to use with the various asserts in the unittest module?
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()
The title method is used to retrieve the title of the webpage the user is currently working on. It gives the title of the current webpage loaded by the driver in selenium, if webpage has no title a null string will be returned.
We can obtain the page title using Selenium webdriver. The method getTitle() is used to obtain the present page title and then we can get the result in the console.
We can find and click elements by title in Selenium webdriver. An element can be identified with a title attribute with xpath or css selector. With the xpath, the expression should be //tagname[@title='value']. In css, the expression should be tagname[title='value'].
I'm not sure what you are asking here.
Other driver.x parameters can be found in documentation or 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With