Q:

After you've found an a WebDriver element, how can you apply an xpath on that element to narrow it down further?

Here's the situation:
My HTML code's structure looks something like this:
XPATH1
     XPATH1 + XPATH2
     XPATH1 + XPATH3
XPATH1
     XPATH1 + XPATH2
     XPATH1 + XPATH3

I need to access those sub-paths. So I"m trying to get all XPATH1s into a list first and then trying to iterate over it.
Unfortunately, this is yielding duplicates for me.
I've got the following code in Python:
elements_list = driver.find_elements_by_xpath(XPATH1)

for element in element_list:
    var1 = element.find_element_by_xpath(XPATH2) #We need XPATH1/XPATH2
    var2 = element.find_element_by_xpath(XPATH3)
    #lots more sub-paths

I suspect that what is happening is, element.find_element_by_xpath(XPATH2) does NOT apply to the element's XPATH. Instead it applies it universally on the page and fetches the whole list of XPATH2s.
I can't use XPATH1 + XPATH2 either because then it's still going to path to each element. 
How can I access each element on this page using a for loop?
Also, is there any use of element.find_element_by_xpath function? It seems practically useless because the xpath gets applied to the entire page.

A:

This is because you didn't specify CONTEXT NODE.
Note you should start your XPATH2 and XPATH3 with the dot that stands for "current context" (XPATH1):
elements_list = driver.find_elements_by_xpath('//div')

for element in element_list:
    var1 = element.find_element_by_xpath('./a')
    var2 = element.find_element_by_xpath('.//p')

This Selenium behavior inherent for search by XPath only. With other methods as find_element_by_css_selector, find_element_by_name, etc... context node should not be specified, so element.find_element_by_css_selector('a') will work fine

