I am trying to automate a process with python and selenium. I have used selenium on different websites before, but on this one, I need to execute javascript and I dont know how, eventhough I found some tutorials on internet.
I need to click Quick Entry in this dropdown menu, I can locate the element with selenium, but I cant execute the javascript.
<li id="MENU_QUICKENTRY" tabindex="0" navigateurl="Quickentry.event" onclick="javascript:return getTabData(this.id,event);">
Quick Entry
</li>
When I normally try .click(), it throws ElementNotInteractableException.
Thank you for all your answers
EDIT: I can click mitigation with .click( and it works, so it can be because it is not visible. ̈
EDIT2: Normally its like this and you have to move your mouse to mitigation to access Quick entry enter image description here
1 Answer 1
This exception is occurred due to other element above (overlapping) your element and when selenium is trying to interact with it another element blocking it. So to avoid this issue we can use ActionChains to move to that element before clicking on it.
wait = WebDriverWait(driver, 20)
element = wait.until(EC.element_to_be_clickable((By.XPATH, "//li[contains(text(),'Quick Entry')]")))
actionChains = ActionChains(driver)
actionChains.move_to_element(element).click().perform()
Please add below import to your solution :
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
Updated section :
menu= wait.until(EC.element_to_be_clickable((By.XPATH, "//*[contains(text(),'Mitigation')]")))
submenu = wait.until(EC.element_to_be_clickable((By.XPATH, "//li[contains(text(),'Quick Entry')]")))
hover = ActionChains(driver)
hover.move_to_element(menu).click()
hover.click(submenu)
hover.perform()
7 Comments
Explore related questions
See similar questions with these tags.