Partial XPath matching

Hello Friends,

Is it possible to locate element by partial xpath matching.
i.e. I want to create a List of web element those contains “//div2/div/div/div/ul/li” in their XPath.

Please Help,

Have you tried using self.driver.find_elements_by_xpath("//div2/div/div/div/ul/li")

Note the plural elements not singular element. It will return a list of all elements that match that xpath vs just the first element that matches that xpath.

Here in my case:
XPath is “//div2/div/div/div/ul/li[XXXXX]”
where XXXXX varies.
so …how to get all elements with XPath Locators containing “//div2/div/div/div/ul/li[”.

Please Help.