'Is there a way to use an XML file to run Selenium tests?

I have a selenium test with over 100 lines of findElement, click(), sendKeys()....

Is there a way I can create an XML or text file of the different parameters and text i want to send in instead of doing all of it a single java file?

There must be a way to shorten my code.



Solution 1:[1]

What you need to do in here is create some layers in the code. Separate the object information from actual code, by creating page objects. with this you will achieve modularity, and get the data out as well from your script. Writing xml file is a good thought but you will run into the same problem again.

Solution 2:[2]

Try using TestNG framework.

TestNG framework is using xml file configurations and parallel execution https://www.toolsqa.com/testng/testng-test/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pallavi
Solution 2 Jayanth Bala