Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Webdriver with Python - driver.title parameter

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()
like image 828
StacyM Avatar asked Oct 09 '13 21:10

StacyM


People also ask

How do you assert the title of a webpage in Selenium Python?

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.

How do you assert the title of a webpage in Selenium?

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.

How do you get the element title in Selenium?

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'].


1 Answers

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
like image 132
Yi Zeng Avatar answered Oct 16 '22 13:10

Yi Zeng