The element you looking for can be uniquely located by the following XPath: //a[contains(.,'commit')].
So, if you want to locate directly all the commit amounts of users on the page this can be done as following:
commits = driver.find_elements(By.XPATH, "//a[contains(.,'commit')]")
for commit in commits:
print(commit.text)
And if you want to locate the commits amount per specific user when you already located the user's block or header element as we do in the previous question, this can be done as following:
header = driver.find_elements(By.XPATH, "//h3[contains(@class,'border-bottom')][contains(.,'Graham')]")
commit = header.find_element(By.XPATH, ".//a[contains(.,'commit')]")
print(commit.text)
Pay attention.
- Here
header.find_element(By.XPATH, ".//a[contains(.,'commit')]") we applied find_element method on header web element object, not on the driver object.
- We use a dot
. at the beginning of the XPath to start searching from the current node (header), not from the beginning of the entire DOM.
UPD
addition can be located with this XPath: //span[@class='cmeta']//span[contains(.,'++')] and deletion with //span[@class='cmeta']//span[contains(.,'--')]