Lamba is something you see used in the Python bindings. But I really love this construct, I've used this to do pseudo dirty page object effectively with the flexibility of using those same element bindings in WebDriverWait statements. I've written about this here, Engineering Quality: Python : Quick and Dirty PageObject Pattern I can go on and on about how awesome this approach is, amongst other things create more resilient element mappings.
Originally Posted by sab15
To better understand Lamba statement, think of them as function pointers. By prefixing it with lambda, you are telling Python you want to pass that code in as a function reference instead of an object. Try this out on a python console
WebDriverWait.until method in the Python bindings takes in a function reference instead of an ExpectedConditions object, like the other compiled languages. What ExpectedConditions object in Python does, is it generates a function reference (effectively creating a lambda statement) What the .until() method will do with any function reference, is it will call it over and over again passing it the webdriver, then it will return whatever the result is when the result is not an error/exception, or it times out.
>>> def foo():
... return 1
>>> type(lambda: 1)
The first method I think is technically more correct. It's the official way of doing it in all the other language bindings, plus in theory more resilient to Selenium API changes. But the 2nd method I prefer due to being much more flexible and powerful. For example, I can define a custom for an element to finish animating much easier with the 2nd construct.