I am using the following script to find elements called 'service_notes' and click the first of them:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import os
driver = webdriver.Firefox(executable_path=r'geckodriver.exe')
driver.get("https://.../sites/frontiersupport/servicenotes/Pages/default.aspx")
os.system("java -jar sikulix.jar -r login.sikuli")
driver.implicitly_wait(5) #
service_notes = driver.find_elements(By.XPATH, '//*/a[starts-with(@href, "/sites/frontiersupport/servicenotes/Lists/SNotes/DispForm.aspx")]')
print(str(service_notes[0]) + ' is the first service note')
print(len(service_notes))
service_notes[0].click()
According to the log, the element is found, but for some reason I can't click it:
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="7505cfd0-5f41-4a8c-af28-bca639e13332", element="c81518a8-5f6c-42fa-8089-5f9469423d7c")> is the first service note
10
Traceback (most recent call last):
File "scraper.py", line 19, in <module>
service_notes[0].click()
File "C:\Users\Joseph\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\Joseph\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "C:\Users\Joseph\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Users\Joseph\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoAlertPresentException: Message: No modal dialog is currently open
The browser is defniitely open, and I'm not sure why the driver is looking for an open 'modal dialog'. This should simply be clicking a link. Any ideas?
Here's the HTML of the link I want to click:
<a onfocus="OnLink(this)" href="/sites/frontiersupport/servicenotes/Lists/SNotes/DispForm.aspx?ID=14686" onclick="GoToLink(this);return false;" target="_self">Firmware 3.04 released for the 850-DS <img src="/_layouts/images/blank.gif" class="ms-hidden" alt="Use SHIFT+ENTER to open the menu (new window)." width="1" height="1" border="0"></a>