I am using Selenium RC in Visual Studio 2010 – Test Project framework. When I try to run the scripts from the share drive I get the following error “Unit Test Adapter threw exception: URI formats are not supported”
The solve the problem please follow the steps:
Double click on Local.testsettings which is under the Solution Items of Project
Test Settings window is displayed. Click on the Deployment link.
You will see a checkbox Enable Deployment. Select the checkbox and click Apply.
The Test Settings can also be found under TraceAndTestImpact.testsettings and just follow the same steps.
Now run your scripts.
Here is the code for the connection to a mysql Database using Microsoft SQL Server JDBC driver.
public void DBtest() throws Exception
// Load Microsoft SQL Server JDBC driver.
// Prepare connection url.
String url = “jdbc:mysql://localhost/TEST_DB”;
// Get connection to DB.
Connection con = DriverManager.getConnection(url, “root”, “admin”);
// Create statement object which would be used in writing DDL and DML
// SQL statement.
Statement stmt = con.createStatement();
// Send SQL SELECT statements to the database via the
// method which returns the requested information as rows of data in a
// ResultSet object.
ResultSet result = stmt.executeQuery(“select email from user”);
// Fetch value of “email_address” from “result” object.
String emailaddress = result.getString(“email”);
// Use the fetched value to login to application.
I use Selenium scripts to do regression testing and I have all the test data in excel. This helps me manage the test data.
When doing regression testing you should have a standard data to test your application. If you are getting the data from the database to run the regression suite and if something fails you are not sure if its because of the test data from the database or because of the changes to the application.
So, I prefer to keep the test data in excel and use it in my selenium scripts.
I hope this will give you an idea of preparing the test data.
Here is code for you to read the data from excel:
string CPPath = @"c:\TestData\HFControlPanel.xls";
Microsoft.Office.Interop.Excel.Application CPapp = new excel.Application();
// create the workbook object by opening the excel file.
excel.Workbook CPworkBook = CPapp.Workbooks.Open(CPPath, 0, true, 5, "", "", true, excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
// Get The Active Worksheet Using Sheet Name Or Active Sheet
ObjectReference ObjectRef = new ObjectReference();
excel.Worksheet CPworkSheet = (worksheet)CPworkBook.Worksheets.get_Item("ControlPanel");
string CPCountry = ((excel.Range)CPworkSheet.get_Range("SelectCountry", Type.Missing)).Value2 as string;
I have seen a lot of people who encounter issue when they are dealing with the windows popup when they have to either upload a file or image.
In this solution I am giving you the page source and the the selenium code. The selenium code is in Visual Studio 2010 C sharp.
selenium.Type("xpath=//input[@type='file' and @name='userfile']", @"c:\testdata\image.png");
How did this solution work for you? Do you have a better alternative? Feel free to share your thoughts in comments section below.