title: Instagram automation with selenium (Python) - Follow and unfollow button
body: <p>I am trying to implement a function which is able to click on the button &quot;follow&quot; when I do not follow the user yet, but that is also able to ignore this part of the code when the text of the button is &quot;unfollow&quot;, that means I am already a follower of the user.</p>
  <p>The code I used is the following:</p>
  <pre class="lang-py prettyprint-override"><code>Follow_Button = browser.find_element_by_xpath(&quot;//*[text()='Follow']&quot;)
  Follow_Button.click()
  </code></pre>
  <p>How can i add an exception to specify to selenium that it should skip this line of code when the text is different from &quot;Follow&quot;?</p>
  <p>Thanks in advance</p>