0

I run a campsite and I'm using Selenium to navigate through my booking system to extract some info. The page I'm trying to navigate has input fields with type=text which is equipped with a date-picker. When I attempt to select the field and use the .send_keys() method, chrome seems to crash. I have also tried to use the .clear() function and manually send the DELETE key x times to clear the field. On each attempt, chrome crashes when I try to clear the last character in the field.

frame = driver.find_element_by_name('theFrame')
driver.switch_to.frame(frame)
print("frame detected")

wait.until((EC.presence_of_element_located((By.NAME, "from"))))
print("from element detected")
sleep(5)
fromfield = driver.find_element_by_name("from")
fromfield.send_keys(f'{yesterday}')
tofield = driver.find_element_by_name("to")
tofield.send_keys(f'{yesterday}')

Is the only way around this to code selenium to operate the date-picker? I can do this, it's just a bit of a pain in the arse and I've not seen this clear = crash issue mentioned elsewhere so wonder whether it's something I'm doing wrong.

Edit: Just to clarify, the page generally seems to crash when this field is cleared. It's not just when using selenium.

Cheers, Simon

  • Does [this](https://stackoverflow.com/a/49748121/14759065) answer your question? – Ananth Jan 01 '21 at 15:34
  • Kind of. So I'm trying to avoid the need to code the operation of the date picker by sending the date keys directly to the input field but I think there is an issue with the JS on the page which means that when the field is cleared of content the page hangs. So it looks like I will indeed need to programme the navigation of the date picker. No biggie, just slightly more long winded than it could otherwise have been. – Simon Sexton Jan 01 '21 at 20:43

1 Answers1

0

You said it has type=text, do you mean that it’s just a normal text box? It depends how the date picker is equipped and what kind of date picker it is if it is to work properly. I think that the problem is with the site and it’s data picker. You could probably program this another way to get it to work.

Hg0428
  • 316
  • 4
  • 15
  • I think you're right that it's an issue with the page and date-picker. I presume the JS is watching the content of the field (the date-picker state changes on key up) and it is failing to handle the that field being empty. I'll just have to code the navigation of the date-picker. No big deal - just a few more lines that would have otherwise been the case. – Simon Sexton Jan 01 '21 at 20:46