I need help with the implementation of the algorithm or can anyone see a ready-made solution for an example.

My task:

There is a file which it is describes (action; xpath). How can I implement this in Java with the help of Selenium?

Test data:

1) File "input". (Xml || xls || txt || json)

2) In the file "input. *" There is an instruction for the Selenium in steps, for example:

UrlOpen; site.com <br>
Click; // * [@ id = "alet"]
  • 3
    Show us what you have tried so far... – Brian Feb 19 '19 at 17:10
  • I would not ask a question if I knew where to start. But at the moment, it’s about how it works with the dataprovider in which the Iterator <String []> is implemented – Temp13 Feb 19 '19 at 17:57
  • 1
    I would start with searching the internet for examples of reading from a dataprovider and using the data. I guarantee there are many examples you can try. If that isn't enough to get you started, you should look at Java tutorials. – Kate Paulk Feb 19 '19 at 18:36

Here's a rough approximation of what you asked for:

public abstract class TestCase {

   private final WebDriver driver;

   public TestClass(WebDriver driver) {
      this.driver = driver;

   protected void urlOpen(url) {

   protected void click(String xpath) {


And how to use it:

public class SampleTestCase extends TestCase {

   public SampleTestCase() {
       super(new FirefoxDriver());

   public void test() {
       click("* [@ id = "alet"]");


It uses your DSL (urlOpen, click keywords) without the need for XML files, text files, etc. Plain Java it is. Thanks to that you don't need any fancy libraries nor business logic for parsing external files, you have IDE autocompletion and debugging support gratis.

| improve this answer | |
  • 1
    Your decision turned out to be the right thing. I completed the desired task. Thank – Temp13 Mar 2 '19 at 6:56

In General you need to use reflection in java. You should try keyword driven automation framework.

below are few good tutorials for it where input maintained in excel (that can be changed as you can implement file reader instead of POI)

https://www.toolsqa.com/selenium-webdriver/keyword-driven-framework/introduction/ https://www.seleniumeasy.com/selenium-tutorials/keyword-driven-framework-example

| improve this answer | |
  • Thank you for taking something from this article. Reputation can not increase ( – Temp13 Mar 2 '19 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.