How can I match the current date in a <td></td> based on datetime.date.today()?
<p>everyone! I'm having some trouble in matching two strings.</p>

<p>So, I've got this HTML code from a page I'm testing:</p>

<pre><code>&lt;td class="fixedColumn ng-binding" 
ng-style="{'padding':'5px','line-height':'10px'}" style="padding: 5px; line-height: 10px;"&gt;

(today's date: 2016-09-23)

&lt;/td&gt;
</code></pre>

<p>The actual string that's displayed in the page is <strong>(today's date: 2016-09-23)</strong>.</p>

<p>What I tried to do using Python is this:</p>

<pre><code>#check if today's date = current date
currentDate = datetime.date.today().strftime("(today's date: %Y-%m-%d)")
todayDate = driver.find_element_by_xpath("//td[contains(text(), 'currentDate']")
allOk = 'all good!'
notOk = 'still not OK...'
if todayDate == currentDate:
    print(allOk)
    home = driver.find_element_by_xpath("//a[@title='Home']").click()
else:
    print(notOk)
    driver.close()
</code></pre>

<p>What happens when I run the script is, obviously, that the browser closes, according to <code>driver.close()</code> , but I need the shell to print 'all good!' in the shell and for the browser to go to "Home" by "clicking".</p>

<p>I'm really new to Python, but as far as I'm concerned, I did everything possible to make this work. Could anyone give me some hints and point out to what I'm missing? Thank you :)</p>

<p>Ok, so it's been about 10 minutes since I've added a comment, but I've made it work.
Code before:</p>

<pre><code>todayDate = driver.find_element_by_xpath("//td[contains(text(), 
" + str(currentDate) + ")]")
</code></pre>

<p>Code after:</p>

<pre><code>todayDate = driver.find_element_by_xpath("//td[contains(text(), 
'" + str(currentDate) + "')]")
</code></pre>

<p>I put  <code>" + str(currentDate) + "</code> in <code>''</code> . Also, I changed</p>

<pre><code>`if todayDate == currentDate:` to `if todayDate:`
</code></pre>

<p>It works as intended now, I only need to figure out why :) anyway, thank you AntlerFox and Jon Clements for your trouble.</p>

python string selenium selenium-webdriver