Hacker News new | ask | show | jobs
by gowan 3211 days ago
you should skip this post. it is full of anti-patterns.

anti-patterns

(1) implicit wait. this will create subtle differences in behavior between drivers. it will also create long pauses when you test for negative conditions.

(2) clear. selenium has built in support for clear[1]. in addition to clear you can send the null key[2] if you want to clear the input midway through a sequence of characters.

(3) time wait. this does not make any sense to me. seems like a clever way to add time.sleep.

[1] https://www.w3.org/TR/webdriver/#element-clear

[2] https://www.w3.org/TR/webdriver/#element-send-keys

1 comments

I agree that implicit wait is something of a time waster.

Regarding clear, that does appear to be exactly what the Python implementation does[0], but in my experience it just seemed to fail at random. If I remember correctly it worked most of the time with geckodriver, and then hardly ever with chromedriver. Really not sure what exactly the deal is with that...

And yes the time wait is a little pointless (:

[0] https://github.com/SeleniumHQ/selenium/blob/master/py/seleni...

clear() works for me consistently. At the same time, I had cases before when sendkeys was not sending complete string, so I had to compare it with get_attribute('value') to be sure.