1

The web page https://www.priceline.com/?tab=cars&vrid=7fb0c3635c8e8e7633afe152907a052e has an <input> element. When I click on it and start typing a <div> with a list of items below appears and I can choose from that list. But when I insert text into that <input> element i.e. the location field, where you see "CIty, Airport or Address" placeholder element on the webpage opened by Selenium, either by actually typing myself or via driver.FindElement(...).SendKeys(...), I see the text, but the list below is not showing.

I don't even know how to approach this. Do I need to configure the driver in a special way?

I assume there is some javascript that intercepts the typing and shows the list below. But, what can be the difference between typing in real life and through Selenium? What can I do?

Selenium Version

  • Selenium.WebDriver - 4.8.0
  • Selenium.WebDriver.ChromeDriver - 110.0.5481.7700
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
theateist
  • 13,879
  • 17
  • 69
  • 109
  • There's nothing special you need to configure. There's something about the way you are entering text that isn't triggering the dropdown of options. Can you post a link to the page? That's about the only way we're going to be able to figure this out. – JeffC Feb 16 '23 at 15:35
  • @JeffC, the page is https://www.priceline.com/?tab=cars&vrid=e20f18b986b0cabdf714f66f53dc6b7c – theateist Feb 16 '23 at 18:09
  • Which field/INPUT are you trying to type into? – JeffC Feb 16 '23 at 18:52
  • To the location field, where you see "CIty, Airport or Address" placeholder – theateist Feb 16 '23 at 19:22

3 Answers3

0

It is possible, the way you are doing it is not simulating typing into the input so the event listener that is listening for that simulation isn't being fired. Try this code below which simulates someone actually typing.

using OpenQA.Selenium.Interactions;

// Find the input element
IWebElement inputElement = driver.FindElement(By.Id("input-element-id"));

// Create an Actions object and send keys to the input element
Actions actions = new Actions(driver);
actions.MoveToElement(inputElement)
       .Click()
       .SendKeys("your text here")
       .Perform();
Michael Rogers
  • 190
  • 1
  • 11
  • I forgot to mention that the list below doesn't show even when I type in that `intput` , on the webpage **OPENED** by Selenium, either by actually typing myself or via the the api. I updated my post. And, I tried your example and it still didn' work. So, probably there is a difference when I do this in real webpage or on the one opened by Selenium. – theateist Feb 16 '23 at 06:52
  • It may not be supported in your Selenium version – Michael Rogers Feb 16 '23 at 06:53
  • I updated my post with the Selenium version that I use. Can you tell me what version do you use and that works for you? – theateist Feb 16 '23 at 06:58
0

The site is detecting Selenium use and blocking use of the site.

If you navigate to the site in a normal browser, typing in the search field works fine.

If you navigate to the site using Selenium and then use the site manually, the dropdown functionality still doesn't work. If you refresh the page, you get sent to a reCATPCHA page with the message, "Access to this page has been denied because we believe you are using automation tools to browse the website."

JeffC
  • 22,180
  • 5
  • 32
  • 55
0

The desired element is a dynamic element, so to send some text e.g. Boston within City, Airport or Address field and click on the matching option you need to induce WebDriverWait for the ElementToBeClickable() and you can use either of the following Locator Strategies:

new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@data-testid='startLocation-typeahead-input']"))).SendKeys("Boston");
new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@data-testid='typeahead-dropdown-card']//div[@role='option' and contains(., 'Boston')]"))).Click();

Browser Snapshot:

Boston

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • It's clear from you screenshot that you made it work. But, no list shows when I try it. It doesn't show neither when I try your code or type it physically by myself. So, maybe it's the way you configure the driver and/or the Selenium version you use and/or you run it as part of unit test or from console? It fails on the second `WebDriverWait` as it cannot find `[@data-testid='typeahead-dropdown-card']` as no list is shown – theateist Feb 17 '23 at 04:01
  • @theateist Hmm, yes, that's right. But I don't have a C# setup. I test my code with Python clients. I just translated the Python stuff into C# – undetected Selenium Feb 17 '23 at 09:08
  • Can you share your driver configuration even if it's in python? – theateist Feb 17 '23 at 14:46