Testing tricks is a blog related to software testing. (Anyone who is interested to write articles or want to share their experience regarding Software Testing are Welcome.) Currently I am working as a Project Manager in QA in Birlasoft. My total experience is in US GL, Property & Casualty & little in Commercial Auto. Working in GWPC with integration as SAP for FSCD & RI shinde.of.santosh@gmail.com
Friday, May 25, 2012
Selenium RC, Junit4 for logging into linkedin.com website
Selenium RC and Junit4 for logging into linkedin.com website
package tests;
import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;
public class ExcelData extends SeleneseTestCase {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.linkedin.com/");
}
@Test
public void testUntitled() throws Exception {
selenium.start();
selenium.open("/");
selenium.type("id=session_key-login", "shinde.of.santosh@gmail.com");
selenium.type("id=session_password-login", "02d91a0433");
selenium.click("id=btn-login");
//selenium.click("id=btn-login");
selenium.isElementPresent("Home");
selenium.waitForPageToLoad("30000");
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}
Thursday, May 17, 2012
clicking on different tabs of google page using xpath
Code for clicking on different tabs of Google page using Xpath
package google;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
public class Xpath {
public static Selenium selenium = null;
public static void testUntitled() throws Exception {
Selenium selenium = new DefaultSelenium("localhost", 4444, "*chrome","http://www.google.co.in/");
selenium.start();
selenium.open("/");
selenium.click("xpath=.//*[@id='gb_119']/span[2]");
selenium.waitForPageToLoad("30000");
verifyTrue(selenium.isTextPresent("Sign In"));
selenium.goBack();
selenium.click("xpath=.//*[@id='gb_1']/span[2]");
selenium.waitForPageToLoad("60000");
assertTrue(selenium.isTextPresent("Google Search"));
selenium.goBack();
selenium.click("xpath=.//*[@id='gb_2']/span[2]");
selenium.waitForPageToLoad("60000");
assertTrue(selenium.isTextPresent(""));
selenium.goBack();
selenium.click("xpath=.//*[@id='gb_8']/span[2]");
selenium.waitForPageToLoad("60000");
selenium.goBack();
selenium.click("xpath=.//*[@id='gb_78']/span[2]");
selenium.waitForPageToLoad("60000");
selenium.goBack();
selenium.click("xpath=.//*[@id='gb_36']/span[2]");
selenium.waitForPageToLoad("60000");
selenium.goBack();
selenium.click("xpath=.//*[@id='gb_5']/span[2]");
selenium.waitForPageToLoad("60000");
selenium.goBack();
selenium.click("xpath=.//*[@id='gb_23']/span[2]");
selenium.waitForPageToLoad("60000");
selenium.goBack();
selenium.click("xpath=.//*[@id='gb_25']/span[2]");
selenium.waitForPageToLoad("60000");
selenium.goBack();
selenium.click("xpath=.//*[@id='gb_24']/span[2]");
selenium.waitForPageToLoad("60000");
selenium.goBack();
}
private static void assertTrue(boolean textPresent) {
// TODO Auto-generated method stub
}
private static void verifyTrue(boolean textPresent) {
// TODO Auto-generated method stub
}
public static void main(String args[]){
try {
Xpath.testUntitled();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Friday, May 4, 2012
Linkedin form filling using Selenium RC
package tests;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
class Linkedin{
public static Selenium selenium = null;
public static void testUntitled() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.linkedin.com//");
selenium.start();
selenium.open("//");
selenium.type("id=firstName-coldRegistrationForm", "santhosh");
selenium.type("id=lastName-coldRegistrationForm", "shinde");
selenium.type("id=email-coldRegistrationForm","santosh_s666@yahoo.com");
selenium.type("id=password-coldRegistrationForm", "santhosh");
selenium.click("id=btn-submit");
selenium.waitForPageToLoad("30000");
}
public static void main(String args[]){
try {
Linkedin.testUntitled();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
code for searching images from google using Selenium Rc
code for searching images from Google using Selenium RC and Eclipse
package tests;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
class SearchImages{
public static Selenium selenium = null;
public static void testUntitled() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.google.co.in//");
selenium.start();
selenium.open("//");
selenium.click("css=#gb_2 > span.gbts");
selenium.waitForPageToLoad("30000");
selenium.type("id=lst-ib", "ram");
selenium.click("name=btnG");
selenium.waitForPageToLoad("50000");
selenium.click("css=i.close_btn");
selenium.waitForPageToLoad("50000");
}
public static void main(String args[]){
try {
SearchImages.testUntitled();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Starting and Stopping selenium server from command prompt
Starting and stopping selenium server from command prompt
Step1: Click on start button
Step2 : Type cmd
Step3: Click ok
Check the folder in which you have selenium-server-standalone-2.21.0.jar file.
If it is in drive then in command prompt type d:
Type java -jar selenium-server-standalone-2.21.0.jar
To stop the selenium server Type CTRL+c from your key board the selenium server will automatically shut down.
Subscribe to:
Posts (Atom)