1

I want to use following functions: get_xpath_count() get_css_count() and others available on http://selenium.googlecode.com/git/docs/api/py/_modules/selenium/selenium.html#selenium.get_xpath_count with selenium object.

But I am not able to create a selenium object to use these functions? Can anyone help?

selenium_user
  • 81
  • 1
  • 6

1 Answers1

1

You are mixing selenium web driver API and Selenium 1 / Selenium RC API: what's the relationship between Selenium RC and WebDriver? is worth reading.

get_xpath_count() and get_css_count() are not a part of selenium WebDriver API.

You can actually simulate get_xpath_count() by calling len() on find_elements_by_xpath() method:

from selenium import webdriver


driver = webdriver.Firefox()
driver.get("https://en.wikipedia.org")

print len(driver.find_elements_by_xpath('//li'))

get_css_count() could be implemented like this:

print len(driver.find_elements_by_tag_name('li'))

Hope that helps.

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195