Python 2.7 如何创建Selenium对象?
我想使用以下功能: 获取\u xpath\u计数() 获取上可用的\u css\u count()和其他内容 使用selenium对象 但是我不能创建一个selenium对象来使用这些函数?Python 2.7 如何创建Selenium对象?,python-2.7,selenium-webdriver,Python 2.7,Selenium Webdriver,我想使用以下功能: 获取\u xpath\u计数() 获取上可用的\u css\u count()和其他内容 使用selenium对象 但是我不能创建一个selenium对象来使用这些函数? 有人能帮忙吗 您正在混合使用selenium web驱动程序API和selenium 1/selenium RC API:值得一读 get\u xpath\u count()和get\u css\u count()不属于 通过调用find\u elements\u by\u xpath()方法上的len()
有人能帮忙吗 您正在混合使用selenium web驱动程序API和selenium 1/selenium RC API:值得一读
get\u xpath\u count()
和get\u css\u count()
不属于
通过调用find\u elements\u by\u xpath()
方法上的len()
,实际上可以模拟get\u xpath\u count()
:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://en.wikipedia.org")
print len(driver.find_elements_by_xpath('//li'))
get\u css\u count()
可以这样实现:
print len(driver.find_elements_by_tag_name('li'))
希望有帮助