Tuesday, August 16, 2011

how to export or take backup mysql database from command promprt in windows

find your mysql location where you installed

C:\Program Files\MySQL\MySQL Server 5.0>

then move to bin folder

C:\Program Files\MySQL\MySQL Server 5.0\bin>

then use this comand

mysql --user=root -proot testdb > export.sql

this will create export.sql file in the bin folder.

if you want to save backup file in the specific path then you give like that

mysql --user=root -proot testdb > d:\db_backup\export.sql

Wednesday, August 3, 2011

How to add 'Selenium IDE in firefox'



How to add 'Selenium IDE in firefox'

Open firefox ( firefox version should be morethan 3.5 v)
move to 'http://seleniumhq.org/download/'
download ide ( click on download version ) and click 'allow' for allowing popup.
restart firefox
move to 'Tools > Selenium IDE'

you can add selenium ide from this page also 'https://addons.mozilla.org/en-US/firefox/addon/flow-control/'

you can add selenium ide from  'Tools > Addons > get addon' > search for selenium and install then restart firefox

Run Selenese Directly Within the Server Using -htmlSuite

Run Selenese Directly Within the Server Using -htmlSuite

 You can run Selenese html files directly within the Selenium Server by passing the html file to the server’s command line. For instance:



java -jar selenium-server-standalone-.jar -htmlSuite "*firefox" "http://www.google.com" "c:\absolute\path\to\my\HTMLSuite.html" "c:\absolute\path\to\my\results.html"


This will automatically launch your HTML suite, run all the tests and save a nice HTML report with the results.


Installing TestNG on Eclipse

Installing TestNG on Eclipse
follow the simple steps below to install the TestNG plug-in on the eclipse IDE.

  • Open the Install/Update window from Help->Software Updates->Find and Install
  • Click on the radio button "Search for new feature to install" and click "Next" button
  • Click on the "New remote site..." and supply name as "TestNG" and URL as "http://beust.com/eclipse" and click on "OK"
  • Make sure the TestNG is checked and click on the "Finish" Button
  • Now follow the other steps and TestNG will be installed.

Monday, May 30, 2011

How To start Selenium



Follow the below steps:

1. Recode your steps in Selenium IDE

2. Have to convert to java code and paste in the eclipse

3. change the class name like sasidhar and save as sasidhar.java.

4. Start the selenium server

5. Execute your script in sclipse.
================================================
package com.example.tests;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

public class sasidhar extends SeleneseTestCase {
    public void setUp() throws Exception {
        setUp("http://www.google.com/", "*firefox");
    }
      public void testNew() throws Exception {
          selenium.open("/");
          selenium.type("q", "selenium rc");
          selenium.click("btnG");
          selenium.waitForPageToLoad("30000");
          assertTrue(selenium.isTextPresent("Results * for selenium rc"));
    }
}
============================================

Thursday, March 10, 2011

MYSQL

How do you start and stop MySQL on Windows?  - net start MySQL, net stop MySQL


What’s the default port for MySQL Server? - 3306


What does tee command do in MySQL? - tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command notee.


Use mysqldump to create a copy of the database? - mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql

Tuesday, March 8, 2011

Connect mysql with selenium



How to connect DB with seleniumRC

First you should now which table want to use and columns names.

Here we are connecting mysql and getting the username and password from "users" table. In this table "userEmail" & "password" columns.

A program can also explicitly load JDBC drivers at any time. For example, the my.sql.Driver is loaded with the following statement:
 Class.forName("my.sql.Driver");

When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from amongst those loaded at initialization
and those loaded explicitly using the same classloader as the current applet or application.

Connect with Mysql/Oracle along with authentication

Connection conn = DriverManager.getConnection(url,"username","password");
then execute quires and store the data in a result set

Now you can use the stored data.
Here is an example for "Login", user email and password getting from the user table with mysql drivers.


// Connect my sql DB and get the user emailid with selenium  
package com.sasidhar.wf;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import com.thoughtworks.selenium.*;
import java.sql.DriverManager;
import java.util.regex.Pattern;

public class Test extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://your applicaiton url/", "*chrome");
}

public void testUntitled() throws Exception {
//this is mysql connection

Class.forName("com.mysql.jdbc.Driver") ;
String url = "jdbc:mysql://database host address/dbname";
Connection conn = DriverManager.getConnection(url,"username","password");
Statement stmt = conn.createStatement();
ResultSet result =  stmt.executeQuery("select useremail from user where userID=1");
while (result.next()) {
String emailaddress = result.getString("userEmail");

selenium.open("your applicaiton url/");
selenium.type("formField1", emailaddress);
selenium.type("formField2", "password");
selenium.click("Login");
selenium.waitForPageToLoad("30000");


}
}
}