0

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.

  • What browser is this using? I tried Chrome in the Java version of Selenium WebDriver, and it clicked Search using the ID fine. So I think it's either a browser issue, or specific to Python. – anonygoose May 24 at 8:11
  • I'm using Chrome. Can you show me the Java code you used, please. – rodut May 24 at 8:32
  • Excluding imports and chromedriver setup and boilerplate, the code was: driver.get("expedia.com/"); driver.findElement(By.id("search-button-hp-package")).click(); – anonygoose May 24 at 8:34
  • Better if you can share your code and the page source code. Have you tried to use a sleep method(not the best method) to wait until the page loads properly? – Joe Jun 26 at 6:50
0

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.

  • Thanks for your time. None of the suggested solutions are working. I can tell for sure that this xpath is working just fine: driver.find_element_by_xpath("//*[@id='gcw-flights-form-hp-flight']/div[7]/label/button").click() But I still can't understand how and why it's working... – rodut May 23 at 19:51
  • Interesting, do you get a different error when trying to click the span? Or is it still ElementNotInteractableException? – mrfreester May 23 at 22:01
  • Yikes, judging by when the icon switches to the hand I think you need to click the label instead... What a gross element! //button[@id='search-button-hp-package']/.. I'll update the answer – mrfreester May 23 at 22:06
  • Same error every time: selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable The last code doesn't work :/ – rodut May 24 at 6:28
0

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.