Showing posts with label Basic Selenium Commands. Show all posts
Showing posts with label Basic Selenium Commands. Show all posts

Database Connection in Selenium


  • Below is the source code to connect your MySQL database with Selenium :
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection ("jdbc:mysql://localhost:3306/demo","username","password");
Statement stmt = (Statement) con.createStatement();
// Below statement we use for executing sql queries.
stmt.executeQuery("Select * from dbtable");

In order to connect, you will need to add one jar file which you can download by clicking here

  • To connect Oracle database with Selenium, write below code:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con =
DriverManager.getConnection("jdbc:oracle:thin:@localhost: 
1521:orcl","username","password");
Statement stmt = con.createStatement();
stmt.executeQuery("Select * from dbtable");

In order to connect, you will need to add one jar file which you can download by clicking here

Selenium Webdriver Commands


This is the key of Selenium Webdriver Commands. These are the most commands which will help you in writing your scripts. 


Selenium WebDriver Commands
Selenium Webdriver Commands