Testing is the main mechanism used in industry to assess and improve the dependability of software systems. To be scalable to the increasingly complex systems that are being developed in many application domains, testing must be automated. However, in many contexts, this is challenging and various techniques from Artificial Intelligence, e.g., machine learning and evolutionary computing, have come to the rescue and have recently shown to alleviate problems that had been thought to be intractable. This talk will cover recent examples of research projects, done in collaboration with industry, and targeting two distinct domains: (1) the security testing of Web applications and (2) the testing of cyber-physical systems. Lessons learned and future research directions will then be discussed.