Selenium: How do I read username and password from an excel file to Java to use in website testing



  • I am using Selenium WebDriver with Java. I have an Excel spreadsheet with two columns, one for username and another for password. I need to read those values and use them to create new users.



  • Well, it depends on the type of excel file. If it is a standard excel file, there is great instructions on reading them here. If it is a CSV based excel file than treat it as reading a standard text file and do a comma (Or whatever delimiter it uses) as a split. Instructions can be found here. After you have the data, I would personally store them to a hashmap or some other system to track the value pair and then loop through the hashmap (Key being username, value being password) using a .keySet() and then check for those values.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2