I'm trying to use python and selenium to click an element without sucess the same way I do when I want to click button elements.
python --version
Python 2.7.16
print selenium.__version__
3.141.0
chromedriver --version
ChromeDriver 2.36
chromium-browser --version
Chromium 65.0.3325.181
This is the tag:
<a data-fblog="the_button" href="javascript:" id="the_btn" class="the_btn" title="Goto">Goto</a>
(that clearly is not defined as a button)
and this is the python part responsible for the click in that tag:
chrome_options = Options()
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
driver = webdriver.Chrome('PATHTOCRHROMEDRIVER/chromedriver',options=chrome_options)
driver.get('https://www.urltogetinfo.com')
try:
the_button = driver.find_element_by_id('the_btn')
the_button.click()
#Also tried these aproaches without sucess:
#the_button = driver.find_element_by_id('the_btn').send_keys(Keys.RETURN)
#the_button = driver.find_element_by_id('the_btn').send_keys(Keys.ENTER)
sleep(5)
except:
print("Problem clicking the button")
#would like to log the exception here
pass
What could I be doing wrong?