title: Python Selenium click button in div
body: <p>So im making a script that clicks some buttons for me in a web browser. </p>
  
  <p>Importing the selenium driver:</p>
  
  <pre><code>from selenium import webdriver
  browser = webdriver.Chrome(executable_path=r'C:/Python27/Scripts/chromedriver.exe')
  </code></pre>
  
  <p>In this example, When i want to click on the "leave hotel" button, i can just use the css_selector and it works fine.</p>
  
  <pre><code>&lt;div id="canvas"&gt;  
  &lt;!--&lt;a onclick="leave_hotel();" name="go_ut" onmousedown="signature.push([Math.floor(Date.now()), 'click']);" class="hotel-button-out"&gt;--&gt;
  &lt;a onclick="leave_hotel();" name="go_ut" onmousedown="" class="hotel-button-out"&gt;Sjekk ut &lt;span style="font-size:0.7em" id="hotell_tid"&gt;(23 t 55 m)&lt;/span&gt;&lt;/a&gt;
          &lt;input type="hidden" name="t" value="cb5a965fbb0a3578344aec059afa7246"&gt;
          &lt;input type="hidden" name="xy" id="xy" value=""&gt;
          &lt;input type="hidden" name="ltoken" value="ea782433046a2e254b10db5045b55d02"&gt;
          &lt;input type="hidden" value="633eacc2bbe92004ba03c9dd57ff9457" name="ttoken"&gt;
          &lt;input type="hidden" name="jtoken" id="jtoken" value=""&gt; 
  &lt;/div&gt;
  </code></pre>
  
  <p>Something like this worked fine:</p>
  
  <pre><code>browser.find_element_by_css_selector('#canvas &gt; a').click()
  </code></pre>
  
  <p>But when i try to click a button within a div on another page, it does not work. the html looks like this:</p>
  
  <pre><code>&lt;div class="canvas hotel-out"&gt;
  &lt;input class=" btn btn-block" name="enkel_knapp" onmousedown="krim_enkel_bego(2);" type="button" id="submit" value="Begå kriminaliteten!"&gt;
  &lt;input type="hidden" name="ltoken" value="e386d141ff442655d48275e0269fe1fe"&gt;
  &lt;input type="hidden" value="2b61bc54fe84d18ae5ad797826152e32" name="ttoken"&gt;
  &lt;input type="hidden" name="jtoken" id="jtoken" value=""&gt;                        
  &lt;input type="hidden" id="xy" value="nytt system (ingen koordinater)" name="xy"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>But the problem is that the buttons xpath is simliar to 3 other buttons. all three buttons got the xpath "//*[@id="submit"]". I guess there is some kind of conflict here?</p>
  
  <p>When i try to do it by name like this i get no respose:</p>
  
  <pre><code>browser.find_element_by_name('enkel_knapp').click()
  </code></pre>
  
  <p>Nothing when i do it by ID either:</p>
  
  <pre><code>browser.find_element_by_id('submit').click()
  </code></pre>
  
  <p>Anyone got any tips to filter by div or something?</p>
  
  <p>The error i get: <a href="https://pastebin.com/E783dXDe" rel="nofollow noreferrer">Pastebin</a></p>