Click button (python), having problems with both mechanize and selenium
<p>I'm trying to click the "Coevolution Scores (TXT)" button that pops up after clicking the "Export..." button, however, using a python script <a href="http://polyview.cchmc.org/cgi-bin/coevolve.cgi?JOB=c8a266e0d7ba7cc" rel="nofollow">here</a>, I could not do it either with mechanize nor selenium, using different selection types.</p>

<p>Is there any other way, or can you possibly figure out what I am doing wrong?</p>

<p>I used this code:</p>

<pre><code>url="http://polyview.cchmc.org/cgi-bin/coevolve.cgi?JOB=c8a266e0d7ba7cc"
driver = webdriver.Chrome(executable_path="C:/ProgramFiles/Google/Chrome/Application/chromedriver.exe")
driver.get(url)
time.sleep(15)
driver.find_element(by=By.XPATH, value="//button[@title='Export...']").click()
</code></pre>

<p>also tried by link_text and by putting <code>find_element_by_link_text</code>, instead of putting the argument inside. Below is the button I try to click.</p>

<pre><code>    &lt;form id="downloadMat" target="formTarget" method="POST" action="coeviz_data.pl"&gt;
            &lt;input name="x" class="idData" type="hidden" value="683436.chi"&gt;
            &lt;input name="dl" class="dlData" type="hidden" value="683436.chi.wph"&gt;
            &lt;input name="w" class="weighted" type="hidden" value="wph"&gt;
            &lt;input name="res" type="hidden" value="scores.txt"&gt;
            &lt;button onclick="submit()"&gt;Coevolution Scores (TXT)&lt;/button&gt;
        &lt;/form&gt;
</code></pre>

<p>The code you are trying to select is inside an <code>&lt;iframe&gt;</code> element. This means that you have to switch frame first before selecting anything that is inside it. This will work:</p>

<pre><code>from selenium import webdriver
import time
from selenium.webdriver.common.by import By
url="http://polyview.cchmc.org/cgi-bin/coevolve.cgi?JOB=c8a266e0d7ba7cc"
driver = webdriver.Chrome(executable_path="C:/ProgramFiles/Google/Chrome/Application/chromedriver.exe")
driver.get(url)
time.sleep(15)
driver.switch_to_frame('ifCoeViz')
driver.find_element(by=By.XPATH, value="//button[@title='Export...']").click()
</code></pre>

python selenium mechanize