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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.