Python - Salesforce: How to find an object with no definitive class name and verify the text?
<p>So, currently I'm using Python 3 and the selenium webdriver with Salesforce to automate admin verifications.</p>

<p>I've been pretty successful (even though I'm not that proficient with programming). However, I've run into an issue... I can't seem to figure out how to find an element on the page so that I can verify the text contained within is accurately being displayed.</p>

<blockquote>
  <p>This is what it looks like on the user's end:
  <a href="https://i.stack.imgur.com/YYaB2.png" rel="nofollow">The highlighted element displays as this </a></p>
</blockquote>

<p>But whenever I search for "GlobalHeaderCommunitySwitcher", it spits back an error that it can't find it.</p>

<p>So I try searching for the other elements in the block of code:</p>

<pre><code>&lt;a href="javascript:void(0)" class="zen-trigger" aria-haspopup="true" id="globalHeaderCommunitySwitcher" title="Press space bar or Enter key to open" data-uidsfdc="51"&gt;&lt;b class="zen-selectArrow"&gt;&lt;/b&gt;PVT GBI Internal&lt;/a&gt;
&lt;b class="zen-selectArrow"&gt;&lt;/b&gt;
"PVT GBI Internal"
</code></pre>

<p>I've come up empty each time by searching by:</p>

<blockquote>
  <p>browser.find_element_by_id("globalHeaderCommunitySwitcher")
     browser.find_element_by_class_name &amp; used "zen-trigger" and "zen-selectArrow"
     browser.find_element_by_xpath("//div[@class='zen-trigger'and text()='PVT GBI Internal']")</p>
</blockquote>

<p>This also results in nothing being returned.. </p>

<p><strong>Essentially, how do I locate the element in the screenshot via the above code and then have the script verify that the text within that element ("PVT GBI INTERNAL") is present and correct?</strong></p>

<p>you can use <code>//tag[text()="value"] or //tag[contains(attribute,âvalueâ)]</code></p>

<p>example : <code>browser.find_element_by_xpath("//a[@class='zen-trigger']//*[ââtext()='PVT GBI Internal']")</code> </p>

<pre><code>//a[@class='zen-trigger']//*[contains(text(),'PVT GBI Internal')]
//a[@class='zen-trigger']//*[contains(@class="zen-selectArrow")and
contains(text(),'PVT GBI Internal')]
</code></pre>

python selenium salesforce