- Selenium Design Patterns and Best Practices
- Dima Kovalenko
- 287字
- 2021-08-05 17:59:44
Chapter 2. The Spaghetti Pattern
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
--Martin Golding
Writing and maintaining any form of software is like fighting entropy; given enough time and changes, any code base will gradually decline into disorder. A test suite is a closed system; if you do not provide energy in constant upkeep and planning, the suite will deteriorate and will fail constantly. Every new feature and line of code added to our website makes our test suite obsolete. The only way to fight back these natural forces is to constantly upgrade and improve existing tests.
In this chapter, we will start to grow our test suite organically and take a look at an anti-pattern called the Spaghetti pattern. Along the way, we will pick up some more basic skills, such as using XPath and CSS selectors to locate the elements on a web page.
Note
The term anti-pattern was inspired by a great book on software design called Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, published by Addison-Wesley Professional and is roughly defined as a common practice, which seems appropriate for current situation, but has a lot of unintended side effects. Furthermore, a better solution for the problem does exist, but is typically ignored in favor of the initial obvious but wrong solution.
In order to write the new tests in this chapter, we will cover the following topics:
- Spaghetti pattern
- Element locator strategies
- XPath and CSS selector query languages
- Relative and absolute path
- Browser inspector tool
- Test run order
- Chain Linked pattern
- Big Ball of Mud pattern
- PHP動態網站程序設計
- LabVIEW 2018 虛擬儀器程序設計
- 自制編譯器
- Vue.js 3.x從入門到精通(視頻教學版)
- 碼上行動:零基礎學會Python編程(ChatGPT版)
- Web Application Development with MEAN
- C程序設計案例教程
- Protocol-Oriented Programming with Swift
- Unity 2017 Mobile Game Development
- IBM Cognos Business Intelligence 10.1 Dashboarding cookbook
- Rust游戲開發實戰
- Neo4j 3.x入門經典
- Java語言程序設計實用教程(第2版)
- Python計算機視覺與深度學習實戰
- Bitcoin Essentials