Mouse hovering action is not happening in selenium and python3

84 views Asked by At

I am automating the Expedia site using selenium(3.12.0) and Pyhton(3.7). I am not able to acheive the mouse hovering action. Error message is:selenium.common.exceptions.ElementNotInteractableException: Message: Element could not be scrolled into view code snippets are as follows:-

driver = webdriver.Firefox()
driver.delete_all_cookies()
driver.get("https://www.expedia.com/")
driver.maximize_window()
driver.set_page_load_timeout(20)
driver.find_element_by_id("tab-flight-tab-hp").click()
driver.find_element_by_id("flight-type-one-way-label-hp-flight").click()
driver.find_element(By.ID, "flight-origin-hp-flight").send_keys("pnq")
driver.find_element(By.ID, "flight-destination-hp-flight").send_keys("ccu")
dep_time = driver.find_element(By.ID, "flight-departing-single-hp-flight")
act = ActionChains(driver)
dep_time.send_keys("03/10/2019")
act.move_to_element(dep_time).click(dep_time).perform()
driver.find_element_by_xpath("//*[@id='search-button-hp-package']").click()
driver.quit()
1

There are 1 answers

0
Jayashree Dhar On

This can be achieved using JavascriptExecutor.

driver.find_element_by_id("tab-flight-tab-hp").click()
driver.find_element_by_id("flight-type-one-way-label-hp-flight").click()
driver.find_element(By.ID, "flight-origin-hp-flight").send_keys("pnq")
driver.find_element(By.ID, "flight-destination-hp-flight").send_keys("ccu")
driver.find_element(By.ID, "flight-departing-single-hp-flight").send_keys("03/10/2019") 
button = driver.find_element_by_xpath("//*[@id='search-button-hp-package']")
driver.execute_script("arguments[0].click();", button)