'Get "XPath" path of element on a page Python Selenium

What method can I use to get the XPath of the object I need on the page automatically by Python tools?

I wanted to do something like this:

from selenium import webdriver

driver = webdriver.Chrome()

driver.get(some_url)

text = input('Input text: ')

for text in driver.page_source:
    cherishedXPath = text.PLEASE_GET_XPATH
    print(cherishedXPath)
else:
    break


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source