Background: For an UI automation large codebase having thousands of Selenium tests, which multiple people have developed/updated/patched over a period of few years. There is no documentation/manual test cases mapping these automated cases as well.We are talking 20k + lines of code with more than 2k + tests.
Problem Statement: Given this big test suite , in which many badly needs update to properly work in first place as many tests are kind of patched just to make it work without much consideration of overall design and structure of the test suite.
Current Situation & Proposed solution:As a QA automation engineer, we need to maintain this suite and keep it updated against current UI however it seems there are deeper issues on the overall design of the code base due to numerous code patches over a long period of time which brings issues like code redundancy, magic numbers,tight coupling & other design issues for which 'refactoring' is the general remedy.
Question:What kind of strategy/approach should be considered to maintain/update/refactor such kind of test code base(mess) considering return on investment in Agile world?
Note: Too much specifics are intentionally not added to keep the question more generic as I am not referring to any specific project but to a more generic test automation problem.