TransWikia.com

Issue using XPath

Software Quality Assurance & Testing Asked by rodut on October 25, 2021

I’m having an issue.
I’m using Selenium and PyCharm.

Website: https://www.expedia.com/

I’m trying to click() on the “Search” button.
I used these:

driver.find_element(By.ID, "search-button-hp-package").click()

driver.find_element_by_xpath("//*[@id='search-button-hp-package']").click()

driver.find_element_by_xpath("//button[@id='search-button-hp-package']").click()

I’m getting the following error:

selenium.common.exceptions.ElementNotInteractableException: Message: element not intractable

Can someone explain me why the element with the id='search-button-hp-package' isn’t intractable? What I’m doing wrong?
Thank you.

3 Answers

The error you are getting is because there would another element overlapping the element you want to click on. Please look at the dom of the website and find out what that element is. Please debug the script you are writing and make sure there no pop ups or any other kind of objects overlapping the element

Answered by Jitendra Jogeshwar on October 25, 2021

Try this in the console if it is working use it of the website $x("//*[@id='search-button-hp-package']/span")

Answered by Pavan N on October 25, 2021

Sometimes websites don't do what you might expect with the elements.

In this case you would expect the button element to be the thing you actually click. But instead it looks to me like the label, which is the parent element, is the element you want to click.

In short, the button is in fact not intractable. So try the some of the surrounding elements instead, parent in this case:

driver.find_element_by_xpath("//*[@id='search-button-hp-package']/..").click()

css selector alternative:

driver.find_element_by_css_selector(".package-form-fields label.search-btn-col").click()

When this happens, you can narrow down what you need to click by looking at what portion of the element you're trying to click is highlighted in dev tools when you look at the surrounding elements.

Answered by mrfreester on October 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP