Selenium code snippets

A curated list of the working code example in Java

Madhan published on
4 min, 689 words

Ever since I published the Selenium cheat sheet people have been asking me this question.

Source — https://imgflip.com/Source — https://imgflip.com/

So I have tried to put all the syntax in the experiment. For this I have used the site the-internet.com developed and maintained by Dave Haeffner.

Let’s see the code snippets.

Note — At the end of this article I have provided a link to the complete source code.

1. A/B Testing

2. Add/Remove Elements

3. Basic Auth

4. Broken Images

5. Checkboxes

6. Context Menu

7. Disappearing Elements

8. Drag and Drop

9. Dropdown

10. Dynamic Content

11. Dynamic Loading

12. Entry Ad

13. Exit Intent

14. File Download

15. File Upload

16. Floating Menu

17. Forgot Password

18. Geolocation

19. Horizontal Slider

20. Hovers

21. Infinite Scroll

22. Inputs

23. JavaScript Alerts

24. JavaScript onload event error

25. JQuery UI Menus

26. Key Presses

27. Login page

28. Login page — Data Driven

29. Multiple Windows

30. Nested Frames

31. Screenshot

32. Status codes

* * * *

Originally published on Medium

🌟 🌟 🌟 The source code for this blog post can be found here 🌟🌟🌟

GitHub - madhank93/automating-internet-app

References:

[1] https://github.com/tourdedave/elemental-selenium-tips

[2] https://stackoverflow.com/questions/47396547/how-to-set-the-geo-location-through-code

[3] https://www.notonlyanecmplace.com/drag-and-drop-external-files-with-selenium/