How to click on a button with Selenium

I try to catch the "next" button in a viewer with Selenium in Python, but nothing works and I get an error message.

The code I executed:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r'chromedriver.exe')
driver.get('https://web.nli.org.il/sites/NLI/Hebrew/digitallibrary/pages/viewer.aspx?&presentorid=MANUSCRIPTS&docid=PNX_MANUSCRIPTS990000907570205171-1')
WebDriverWait(driver, 10)

Until now, everything has been fine. This is where the issue arises.

I want to click on the next arrow: enter image description here

I get the following code while inspecting the source code of this arrow: <div id="next" class="left"><a href="#" title="next">&nbsp;</a></div>

So these are my attempts:

XPath

driver.find_elements_by_xpath('//*[@id="next"]')

returns an empty list.

id

driver.find_elements_by_id("next")

returns an empty list.

So, how can I catch this button and click on it?



Read more here: https://stackoverflow.com/questions/68459078/how-to-click-on-a-button-with-selenium

Content Attribution

This content was originally published by Yanirmr at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: