Python webdriver: get XPATH from innerHTML
<p>Is there a way to get the xpath of an webelement knowing only its innerHTML value?</p>

<p>Say I've got a 'Save' button, which is a button with text "Save". Say that the button can change its location on the page with subsequent updates to the system, therefore changing its xpath every time.</p>

<p>Here is an example bit from the page source:</p>

<pre><code>&lt;button ng-click="Model.Save()" ng-disabled="Model.SavingChecklist" href="javascript:void(0)" class="btn" translate=""&gt;
  &lt;span class="ng-scope"&gt;Save&lt;/span&gt;
&lt;/button&gt;
</code></pre>

<p>I want to search the page for the innerHTML value "Save" and return the xpath (of the second line).
Note that "Save" is not a link.</p>

<p>Is it possible?</p>

<p>You can use following <code>XPath</code> to match any element with <code>innerHTML="Save"</code>:</p>

<pre><code>//*[text()="Save"]
</code></pre>

<p>or in your case:</p>

<pre><code>//button/span[text()="Save"]
</code></pre>

python selenium xpath