Connect Remote Database using Selenium Webdriver and run Test Cases from local machine through eclipse Connect Remote Database using Selenium Webdriver and run Test Cases from local machine through eclipse selenium selenium

Connect Remote Database using Selenium Webdriver and run Test Cases from local machine through eclipse


You just need to specify machine's IP address, port and database name in the connection string. So try something like

String dbUrl = "jdbc:mysql://192.168.1.53306/myDB";DriverManager.getConnection(dbUrl, "username", "password");

And your tests should work the same way as before, you are just connectng to the different machine which can be more time consuming (e.g. queries can take more time) but that's the only difference.


You can utilize data driven capability provided by one of the selenium testing-frameworks - ISFW where you can specify data base query to provide test data.For example:

@IsDataProvider(sqlQuery="select query")@Testpublic void testSomething(Map<String, String> testdata){  //use query col as key testdata.get("colName")  }


You need to add a jar file to connect to the database

jar: mysql-connector-java