selenium jargon

Upload: anilsahumits

Post on 14-Oct-2015

592 views

Category:

Documents


2 download

TRANSCRIPT

  • 5/24/2018 Selenium Jargon

    1/401

    JUNIT INTERVIEW QUESTIONSInterview Questions

    What Is JUnit?

    Who Should Use JUnit, Developers or Testers?

    Why Do You Use JUnit to Test Your Code? Do You Know the Book "JUnit Recipes: Practical Methods for ProgrammerTesting"?

    Do You Know the Book "JUnit in Action"?

    Where Do You Download JUnit?

    How Do You Install JUnit?

    What Articles Have You Read about JUnit?

    How To Wirte a Simple JUnit Test Class?

    How To Compile a JUnit Test Class?

    How To Run a JUnit Test Class? What CLASSPATH Settings Are Needed to Run JUnit?

    How Do I Run JUnit Tests from Command Window?

    How Do You Uninstall JUnit?

    How To Write a JUnit Test Method?

    Can You Provide a List of Assertion Methods Supported by JUnit 4.4?

    What Happens If a JUnit Test Method Is Declared as "private"?

    What Happens If a JUnit Test Method Is Declared to Return "String"?

    Why Does Poeple Import org.junit.Assert Statically?

    How To Group Multiple Test Classes into a Suite in JUnit 4.4? How To Run a "@Suite.SuiteClasses" Class in JUnit 4.4?

    What Is the "@SuiteClasses" Annotation?

    Why Not Just Use a Debugger for Unit Testing?

    Why Not Just Write a main() Method for Unit Testing?

    Why Not Just Use System.out.println() for Unit Testing?

    Under What Conditions Should You Test set() and get() Methods?

    Under What Conditions Should You Not Test Get() and Set() Methods?

    Do You Need to Write a Test Class for Every Class That Need to Be

    Tested? What Is JUnit TestCase?

    What Is JUnit TestSuite?

    How Many Test Runners Are Supported in JUnit 3.8?

    What Are JUnit 3.8 Naming Conventions?

    How To Write a Single Class to Define Multiple Tests and Run Them?

    How to Run Your JUnit 4.4 Tests with a JUnit 3.8 Runner?

    http://sqa.fyicenter.com/FAQ/JUnit/What_Is_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Who_Should_Use_JUnit_Developers_or_Testers_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Who_Should_Use_JUnit_Developers_or_Testers_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Do_You_Use_JUnit_to_Test_Your_Code_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Do_You_Use_JUnit_to_Test_Your_Code_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Know_the_Book_JUnit_Recipes_Practical_M.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Know_the_Book_JUnit_Recipes_Practical_M.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Know_the_Book_JUnit_Recipes_Practical_M.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Know_the_Book_JUnit_Recipes_Practical_M.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Know_the_Book_JUnit_Recipes_Practical_M.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Know_the_Book_JUnit_in_Action_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Know_the_Book_JUnit_in_Action_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Where_Do_You_Download_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Where_Do_You_Download_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Install_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Install_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Articles_Have_You_Read_about_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Articles_Have_You_Read_about_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Wirte_a_Simple_JUnit_Test_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Wirte_a_Simple_JUnit_Test_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Compile_a_JUnit_Test_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Compile_a_JUnit_Test_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Run_a_JUnit_Test_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Run_a_JUnit_Test_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_CLASSPATH_Settings_Are_Needed_to_Run_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_CLASSPATH_Settings_Are_Needed_to_Run_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_I_Run_JUnit_Tests_from_Command_Window_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_I_Run_JUnit_Tests_from_Command_Window_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Uninstall_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Uninstall_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Write_a_JUnit_Test_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Write_a_JUnit_Test_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Provide_a_List_of_Assertion_Methods_Supp.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Provide_a_List_of_Assertion_Methods_Supp.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_a_JUnit_Test_Method_Is_Declared_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_a_JUnit_Test_Method_Is_Declared_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_a_JUnit_Test_Method_Is_Declared__18.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_a_JUnit_Test_Method_Is_Declared__18.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Does_Poeple_Import_org_junit_Assert_Statical.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Does_Poeple_Import_org_junit_Assert_Statical.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Group_Multiple_Test_Classes_into_a_Suite_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Group_Multiple_Test_Classes_into_a_Suite_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Run_a_Suite_SuiteClasses_Class_in_JUni.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Run_a_Suite_SuiteClasses_Class_in_JUni.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_the_SuiteClasses_Annotation_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_the_SuiteClasses_Annotation_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Not_Just_Use_a_Debugger_for_Unit_Testing_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Not_Just_Use_a_Debugger_for_Unit_Testing_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Not_Just_Write_a_main_Method_for_Unit_Test.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Not_Just_Write_a_main_Method_for_Unit_Test.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Not_Just_Use_System_out_println_for_Unit_T.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Not_Just_Use_System_out_println_for_Unit_T.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Under_What_Conditions_Should_You_Test_set_and_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Under_What_Conditions_Should_You_Test_set_and_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Under_What_Conditions_Should_You_Not_Test_Get_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Under_What_Conditions_Should_You_Not_Test_Get_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Need_to_Write_a_Test_Class_for_Every_Clas.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Need_to_Write_a_Test_Class_for_Every_Clas.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Need_to_Write_a_Test_Class_for_Every_Clas.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Need_to_Write_a_Test_Class_for_Every_Clas.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Need_to_Write_a_Test_Class_for_Every_Clas.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_JUnit_TestCase_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_JUnit_TestCase_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_JUnit_TestSuite_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_JUnit_TestSuite_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Many_Test_Runners_Are_Supported_in_JUnit_3_8.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Many_Test_Runners_Are_Supported_in_JUnit_3_8.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Are_JUnit_3_8_Naming_Conventions_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Are_JUnit_3_8_Naming_Conventions_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Write_a_Single_Class_to_Define_Multiple_T.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Write_a_Single_Class_to_Define_Multiple_T.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_to_Run_Your_JUnit_4_4_Tests_with_a_JUnit_3_8.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_to_Run_Your_JUnit_4_4_Tests_with_a_JUnit_3_8.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_to_Run_Your_JUnit_4_4_Tests_with_a_JUnit_3_8.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Write_a_Single_Class_to_Define_Multiple_T.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Are_JUnit_3_8_Naming_Conventions_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Many_Test_Runners_Are_Supported_in_JUnit_3_8.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_JUnit_TestSuite_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_JUnit_TestCase_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Need_to_Write_a_Test_Class_for_Every_Clas.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Need_to_Write_a_Test_Class_for_Every_Clas.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Under_What_Conditions_Should_You_Not_Test_Get_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Under_What_Conditions_Should_You_Test_set_and_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Not_Just_Use_System_out_println_for_Unit_T.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Not_Just_Write_a_main_Method_for_Unit_Test.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Not_Just_Use_a_Debugger_for_Unit_Testing_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_the_SuiteClasses_Annotation_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Run_a_Suite_SuiteClasses_Class_in_JUni.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Group_Multiple_Test_Classes_into_a_Suite_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Does_Poeple_Import_org_junit_Assert_Statical.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_a_JUnit_Test_Method_Is_Declared__18.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_a_JUnit_Test_Method_Is_Declared_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Provide_a_List_of_Assertion_Methods_Supp.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Write_a_JUnit_Test_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Uninstall_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_I_Run_JUnit_Tests_from_Command_Window_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_CLASSPATH_Settings_Are_Needed_to_Run_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Run_a_JUnit_Test_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Compile_a_JUnit_Test_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Wirte_a_Simple_JUnit_Test_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Articles_Have_You_Read_about_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Install_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Where_Do_You_Download_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Know_the_Book_JUnit_in_Action_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Know_the_Book_JUnit_Recipes_Practical_M.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Know_the_Book_JUnit_Recipes_Practical_M.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Do_You_Use_JUnit_to_Test_Your_Code_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Who_Should_Use_JUnit_Developers_or_Testers_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_JUnit_.html
  • 5/24/2018 Selenium Jargon

    2/401

    Can You Write a Simple Class for JUnit Testing in 1 Minute?

    Can You Write a JUnit Test Case Class in 2 Minutes?

    Can You Write a JUnit Test Suite in 2 Minutes?

    Where Should You Place Test Classes?

    How Do You Test a "protected" Method? How Do You Test a "private" Method?

    Can You Write a JUnit Test Case Class in 10 Minutes?

    Can You Explain a Sample JUnit Test Case Class?

    Do You Need to Write a main() Method in a JUnit Test Case Class?

    How To Group Test Cases Class using JUnit TestSuite?

    Can You Write a JUnit 4.4 Test Class Template in 2 Minutes?

    Can You Explain the Life Cycle of a JUnit 4.4 Test Class?

    How To Write Setup Code to Run Once for All Tests in a Test Class?

    Can You Write a JUnit 3.8 Test Class Template in 2 Minutes? Can You Explain the Life Cycle of a JUnit 3.8 Test Case Class?

    What Is a JUnit Test Fixture?

    Can You Create Tests without Using a Common Test Fixture?

    How Create a Test Fixture to Be Shared by All Tests in a Test Class?

    How To Destroy a JUnit Test Fixture?

    When Do You Need to Write an @After Method?

    When Should Unit Tests Should Be Written In Development Cycle?

    How Do You Launch a Debugger When a Test Fails?

    How Do You Run JUnit Using Ant? How Do You Run All Test Classes without Managing a TestSuite Explicitly?

    How Do You Test an Expected Exception with JUnit?

    How To Use the "expected" Parameter Supported by the "@Test"Annotation?

    How Do You Test an Unexpected Exception with JUnit?

    What Happens If a Test Method Throws an Exception?

    Why Do I See "Unknown Source" in the Stack Trace of a Failed Test?

    How Do You Test a Method That Doesn't Return Anything?

    When Objects Are Garbage Collected After a Test Is Executed? What Is Java "assert" Statement?

    How To Test Programs Thats Use Java "assert" Statements?

    Should You Run JUnit Tests with Java Assertion Disabled?

    What Happens If You Run JUnit Tests with Java Assertion Enabled?

    Why Does JUnit Only Report the First Failed Assertion in a Single Test?

    Do You Have To Write a Test for Everything?

    http://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_Simple_Class_for_JUnit_Testing_i.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_Simple_Class_for_JUnit_Testing_i.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_Test_Case_Class_in_2_Minut.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_Test_Case_Class_in_2_Minut.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_Test_Suite_in_2_Minutes_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_Test_Suite_in_2_Minutes_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Where_Should_You_Place_Test_Classes_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Where_Should_You_Place_Test_Classes_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_a_protected_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_a_protected_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_a_private_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_a_private_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_Test_Case_Class_in_10_Minu.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_Test_Case_Class_in_10_Minu.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_a_Sample_JUnit_Test_Case_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_a_Sample_JUnit_Test_Case_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Need_to_Write_a_main_Method_in_a_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Need_to_Write_a_main_Method_in_a_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Group_Test_Cases_Class_using_JUnit_TestSu.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Group_Test_Cases_Class_using_JUnit_TestSu.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_4_4_Test_Class_Template_in.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_4_4_Test_Class_Template_in.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_the_Life_Cycle_of_a_JUnit_4_4_Te.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_the_Life_Cycle_of_a_JUnit_4_4_Te.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Write_Setup_Code_to_Run_Once_for_All_Test.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Write_Setup_Code_to_Run_Once_for_All_Test.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_3_8_Test_Class_Template_in.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_3_8_Test_Class_Template_in.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_the_Life_Cycle_of_a_JUnit_3_8_Te.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_the_Life_Cycle_of_a_JUnit_3_8_Te.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_a_JUnit_Test_Fixture_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_a_JUnit_Test_Fixture_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Create_Tests_without_Using_a_Common_Test.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Create_Tests_without_Using_a_Common_Test.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Create_a_Test_Fixture_to_Be_Shared_by_All_Te.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Create_a_Test_Fixture_to_Be_Shared_by_All_Te.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Destroy_a_JUnit_Test_Fixture_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Destroy_a_JUnit_Test_Fixture_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/When_Do_You_Need_to_Write_an_After_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/When_Do_You_Need_to_Write_an_After_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/When_Should_Unit_Tests_Should_Be_Written_In_Deve.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/When_Should_Unit_Tests_Should_Be_Written_In_Deve.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Launch_a_Debugger_When_a_Test_Fails_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Launch_a_Debugger_When_a_Test_Fails_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Run_JUnit_Using_Ant_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Run_JUnit_Using_Ant_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Run_All_Test_Classes_without_Managing.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Run_All_Test_Classes_without_Managing.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_an_Expected_Exception_with_JUnit.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_an_Expected_Exception_with_JUnit.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Use_the_expected_Parameter_Supported_by.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Use_the_expected_Parameter_Supported_by.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Use_the_expected_Parameter_Supported_by.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Use_the_expected_Parameter_Supported_by.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Use_the_expected_Parameter_Supported_by.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_an_Unexpected_Exception_with_JUn.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_an_Unexpected_Exception_with_JUn.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_a_Test_Method_Throws_an_Exceptio.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_a_Test_Method_Throws_an_Exceptio.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Do_I_See_Unknown_Source_in_the_Stack_Trace.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Do_I_See_Unknown_Source_in_the_Stack_Trace.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_a_Method_That_Doesn_t_Return_Any.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_a_Method_That_Doesn_t_Return_Any.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/When_Objects_Are_Garbage_Collected_After_a_Test_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/When_Objects_Are_Garbage_Collected_After_a_Test_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_Java_assert_Statement_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_Java_assert_Statement_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Test_Programs_Thats_Use_Java_assert_Sta.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Test_Programs_Thats_Use_Java_assert_Sta.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Should_You_Run_JUnit_Tests_with_Java_Assertion_D.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Should_You_Run_JUnit_Tests_with_Java_Assertion_D.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_You_Run_JUnit_Tests_with_Java_As.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_You_Run_JUnit_Tests_with_Java_As.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Does_JUnit_Only_Report_the_First_Failed_Asse.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Does_JUnit_Only_Report_the_First_Failed_Asse.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Have_To_Write_a_Test_for_Everything_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Have_To_Write_a_Test_for_Everything_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Have_To_Write_a_Test_for_Everything_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Does_JUnit_Only_Report_the_First_Failed_Asse.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_You_Run_JUnit_Tests_with_Java_As.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Should_You_Run_JUnit_Tests_with_Java_Assertion_D.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Test_Programs_Thats_Use_Java_assert_Sta.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_Java_assert_Statement_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/When_Objects_Are_Garbage_Collected_After_a_Test_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_a_Method_That_Doesn_t_Return_Any.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Why_Do_I_See_Unknown_Source_in_the_Stack_Trace.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Happens_If_a_Test_Method_Throws_an_Exceptio.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_an_Unexpected_Exception_with_JUn.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Use_the_expected_Parameter_Supported_by.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Use_the_expected_Parameter_Supported_by.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_an_Expected_Exception_with_JUnit.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Run_All_Test_Classes_without_Managing.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Run_JUnit_Using_Ant_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Launch_a_Debugger_When_a_Test_Fails_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/When_Should_Unit_Tests_Should_Be_Written_In_Deve.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/When_Do_You_Need_to_Write_an_After_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Destroy_a_JUnit_Test_Fixture_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Create_a_Test_Fixture_to_Be_Shared_by_All_Te.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Create_Tests_without_Using_a_Common_Test.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Is_a_JUnit_Test_Fixture_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_the_Life_Cycle_of_a_JUnit_3_8_Te.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_3_8_Test_Class_Template_in.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Write_Setup_Code_to_Run_Once_for_All_Test.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_the_Life_Cycle_of_a_JUnit_4_4_Te.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_4_4_Test_Class_Template_in.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Group_Test_Cases_Class_using_JUnit_TestSu.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Do_You_Need_to_Write_a_main_Method_in_a_JUnit_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_a_Sample_JUnit_Test_Case_Class_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_Test_Case_Class_in_10_Minu.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_a_private_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_a_protected_Method_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Where_Should_You_Place_Test_Classes_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_Test_Suite_in_2_Minutes_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_JUnit_Test_Case_Class_in_2_Minut.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Write_a_Simple_Class_for_JUnit_Testing_i.html
  • 5/24/2018 Selenium Jargon

    3/401

    How Often Should You Run Your JUnit Tests?

    What Do You Do When a Defect Is Reported?

    How simple is 'too simple to break'?

    How To Verify the JUnit Plugin in Eclipse?

    How To Create Test Class in Eclipse? How to Run a JUnit Test Case in Eclipse?

    Can You Describe Steps of Creating Test Case Classes in Eclipse?

    How to creating a Test Suite using JUnit in Eclipse?

    How Do You Use Ant to Create HTML Test Reports?

    How Do You Test Classes That Must Be Run in a J2EE Container?

    Can You Explain the Exception: "No runnable methods"?

    -----------------------------------------------------------------------------------------

    Transcript of Selenium and WebDriver

    Selenium What is Selenium? The name comes from the Greek selene meaning "Moon"

    Selenium 1, bye-bye! WebDriver Selenium occurs in three distinct forms: as a non-crystalline

    (gray);

    it can form

    as a deep

    red to black

    powder; and it can form as red crystals. Selenium is a chemical element with atomic number 34,

    chemical symbol Se, and an atomic mass of 78.96. It is a nonmetal, whose properties are

    intermediate between those of adjacent chalcogen elements sulfur and tellurium. In nature In

    testing The tests can then be run against most modern web

    browsers. Selenium deploys on

    Windows, Linux,

    and Macintosh platforms.

    Thank you! Selenium is a portable software testing framework for web applications.

    Selenium provides a record/playback tool for authoring tests without learning a test scripting

    language (Selenium IDE). It also provides a test domain-specific language (Selenese) to write

    tests in a number of popular programming languages, including C#, Java, Groovy, Perl, PHP,

    Python and Ruby. :

    http://www.cs.colostate.edu

    http://www.sibgames.net

    http://demiart.ru

    http://www.spletnik.ru 7.WebDriver is on its way to

    becoming a browser standard. WebDriver: WebDriver

    http://sqa.fyicenter.com/FAQ/JUnit/How_Often_Should_You_Run_Your_JUnit_Tests_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Often_Should_You_Run_Your_JUnit_Tests_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Do_You_Do_When_a_Defect_Is_Reported_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Do_You_Do_When_a_Defect_Is_Reported_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_simple_is_too_simple_to_break_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_simple_is_too_simple_to_break_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Verify_the_JUnit_Plugin_in_Eclipse_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Verify_the_JUnit_Plugin_in_Eclipse_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Create_Test_Class_in_Eclipse_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Create_Test_Class_in_Eclipse_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_to_Run_a_JUnit_Test_Case_in_Eclipse_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_to_Run_a_JUnit_Test_Case_in_Eclipse_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Describe_Steps_of_Creating_Test_Case_Cla.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Describe_Steps_of_Creating_Test_Case_Cla.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_to_creating_a_Test_Suite_using_JUnit_in_Ecli.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_to_creating_a_Test_Suite_using_JUnit_in_Ecli.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Use_Ant_to_Create_HTML_Test_Reports_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Use_Ant_to_Create_HTML_Test_Reports_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_Classes_That_Must_Be_Run_in_a_J2.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_Classes_That_Must_Be_Run_in_a_J2.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_the_Exception_No_runnable_meth.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_the_Exception_No_runnable_meth.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Explain_the_Exception_No_runnable_meth.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Test_Classes_That_Must_Be_Run_in_a_J2.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Do_You_Use_Ant_to_Create_HTML_Test_Reports_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_to_creating_a_Test_Suite_using_JUnit_in_Ecli.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/Can_You_Describe_Steps_of_Creating_Test_Case_Cla.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_to_Run_a_JUnit_Test_Case_in_Eclipse_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Create_Test_Class_in_Eclipse_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_To_Verify_the_JUnit_Plugin_in_Eclipse_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_simple_is_too_simple_to_break_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/What_Do_You_Do_When_a_Defect_Is_Reported_.htmlhttp://sqa.fyicenter.com/FAQ/JUnit/How_Often_Should_You_Run_Your_JUnit_Tests_.html
  • 5/24/2018 Selenium Jargon

    4/401

    What is it?

    What does it do? WebDriver is a tool for automating testing web applications, and in particular

    to verify that they work as expected. It aims to provide a friendly API that's easy to explore and

    understand, which will help make your tests easier to read and maintain. It's not tied to any

    particular test framework, so it can be used equally well with JUnit, TestNG or from a plain old"main" method. And then?! And what's the difference between

    WebDriver and Selenium? The main difference is hidden in the architecture of these tools

    Comparison Let's look at these differences

    a bit more closely! Here the presentation comes to an end... 5. Window

    An interface for managing size and

    position of window browser Interface WebDriver The main interface used for testing, which

    represents an idealised web browser.

    The methods in this class fall into three categories: - Control of the browser itself (get(),

    navigate(), close(), etc)

    - Selection of WebElements (findElement(), findElements(), etc)

    - Debugging aids (getCurrentUrl(), getPageSource(), getWindowHandles(), etc) WebDriver has

    six major Interfaces : 0. ImeHandler

    An interface for managing input methods 1. Navigation

    Used to move between sites in the current window 2. Options

    An interface for managing stuff you would do in a browser menu 3. TargetLocator

    Used to locate a given frame or window 4. Timeouts

    An interface for managing timeout behavior for WebDriver instances. Let's start! Locating UI

    Elements 2. Once youve finished filling out the form, you probably want to submit it. One way

    to do this is would be to find the submit button and click it:

    driver.findElement(By.id("submit")).click(); Alternatively, WebDriver has the convenient

    "submit" method on every element:

    element.submit(); Select multiple items

    driver.get("http://jqueryui.com/demos/selectable/");

    WebElement item1 = driver.findElement(By.xpath("//li[.='Item 1']"));

    WebElement item2 = driver.findElement(By.xpath("//li[.='Item 2']"));

    //First, configure it:

    Actions builder = new Actions(driver);

  • 5/24/2018 Selenium Jargon

    5/401

    builder.clickAndHold(item1)

    .clickAndHold(item2)

    .click() ;

    //Then get the action:Action selectMultiple = builder.build();

    //And execute it:

    selectMultiple.perform(); Tips, Hacks & Hidden Features Javascript Alerts WebDriver supported

    Javascript alerts

    // Get a handle to the open alert, prompt or confirmation

    Alert alert = driver.switchTo().alert();

    // Get the text of the alert or prompt

    alert.getText();

    // And acknowledge the alert (equivalent to clicking "OK")

    alert.accept(); Drag And Drop Drag an element to an offset

    driver.get("http://jqueryui.com/demos/draggable/");

    WebElement dragItem = driver.findElement(By.id("draggable"));

    (new Actions(driver)).dragAndDropBy(dragItem, 5, 10).build().perform(); Press control+...

    textBox.sendKeys(Keys.LEFT_CONTROL + "a");

    textBox.sendKeys(Keys.LEFT_CONTROL + "c");

    textBox.sendKeys(Keys.LEFT_CONTROL + "v");

    textBox.sendKeys(Keys.LEFT_CONTROL, Keys.F5); Sequence of actions Proxy Proxy

    configuration

    Proxy proxy = new Proxy();

    proxy.setProxyAutoconfigUrl("http://yourdomain/config");

    DesiredCapabilities capabilities =DesiredCapabilities.firefox();

    capabilities.setCapability(CapabilityType.PROXY, proxy); Scrolls a window It is possible to use

    Javascript execution abilities:

    int pixel = 500;

    ((JavascriptExecutor) driver)

  • 5/24/2018 Selenium Jargon

    6/401

    .executeScript("if (window.screen){window.scrollBy(0," + pixel + ");};"); Start Firefox with an

    extension installed File file = new File("firebug-1.9.0-fx.xpi");

    FirefoxProfile firefoxProfile = new FirefoxProfile();

    firefoxProfile.addExtension(file);

    WebDriver driver = new FirefoxDriver(firefoxProfile); By ID

    This is the most efficient and prefered way to locate an element. Common pitfalls that UI

    developers make is having non-unique ids on a page or auto-generating the id, both should be

    avoided. A class on an html element is more appropriate than an auto-generated id.

    WebElement captchaBox = driver.findElement(By.id("ConfirmMainEmailForm_captcha")); By

    Name

    Finds the element with matching name attribute.

    WebElement captchaBox = driver.findElement(By.name("ConfirmMainEmailForm[captcha]"));

    By Link Text

    Find the link element with matching visible text.

    WebElement signInButton =

    driver.findElement(By.linkText("Sign in and register")); By Partial Link Text

    Find the link element with partial matching visible text.

    WebElement signInButton =

    driver.findElement(By.partialLinkText("Sign in")); By CSS

    Like the name implies it is a locator strategy by css.

    Please,beware that not all browsers were created equal, some css that may work in one version -

    may not work in another.

    WebElement signInButton = driver.findElement(By.cssSelector(".bUserBar .LikeRealBtn")); ByXPATH

    At a high level, WebDriver uses a browsers native XPath capabilities wherever possible.

    List radioButtons =

    driver.findElements(By.xpath("//input[@class='bTicketPaper__eRadioButton']"));

  • 5/24/2018 Selenium Jargon

    7/401

    List radioButtonsVisible =

    driver.findElements(By.xpath("//input[@class='bTicketPaper__eRadioButton' and

    not(@disabled='disabled')]")); Let's solve the problem:

    Find all radio buttons circled in the picture The same result we get if we use as a locator class

    name.

    By Class Name

    Class in this case refers to the attribute on the DOM element. Often in practicle use there are

    many DOM elements with the same class name, thus finding multiple elements becomes the

    more pratical option over finding the first element.

    List radioButtons =

    driver.findElements(By.className("bTicketPaper__eRadioButton")); I almost forgot ... By Tag

    Name

    The DOM Tag Name of the element.

    Let's resolve the issue: How do We get the entire text of the page? WebElement bodyOfPage =

    driver.findElement(By.tagName("body"));

    String bodyText = bodyOfPage.getText(); 0. Locating UI Elements

    Each of the language bindings expose a Find Element and Find Elements method.

    The Find methods take a locator or query object called By. By strategies are listed further.

    1. Typing into an element

    If you want to enter some text into a text field, then you can use:

    element.sendKeys("some text");

    A side-effect of this is that typing something into a text field wont automatically clear it.

    Instead, what you type will be appended to whats already there. You can easily clear the

    contents of a text field or textarea:

    element.clear(); Work with a slider

    driver.get("http://jqueryui.com/demos/slider/range.html");

    WebElement dragItem =

    driver.findElement(By.xpath("//a[@class='ui-slider-handle ui-state-default ui-corner-all']"));

    (new Actions(driver)).dragAndDropBy(dragItem, 10, 0).build().perform(); Drag an element to

  • 5/24/2018 Selenium Jargon

    8/401

    drop on to another element

    driver.get("http://jqueryui.com/demos/droppable/");

    WebElement fromItem1 = driver.findElement(By.id("draggable"));

    WebElement toItem2 = driver.findElement(By.id("droppable"));(new Actions(driver)).dragAndDrop(fromItem1, toItem2).build().perform(); Executing JavaSript

    WebDriver driver; // Assigned elsewhere

    JavascriptExecutor js = (JavascriptExecutor)driver;

    js.executeScript("alert('Selenium1 bye-bye')"); 1. Selenium works through proxy using

    Javascript. 1. WebDriver works natively with Browser

    (Native automation faster and a little less

    prone to error and browser configuration).

    2. Selenium supports major browsers.

    (IE, Firefox, Chrome, Safari, Opera) 2. WebDriver supports IE, Firefox, Opera,

    Chrome, and also Android and IPhone Drivers. 3. Selenium API is quite complicated 3. Great

    Simple API. 4. Selenium supports multiple

    languages to write the test.

    (C#, Java, Groovy, Perl, PHP,

    Python and Ruby) 4. Perl and PHP are not supported in WebDriver

    (December 2011).

    A pure JS API support is also in the planning stage. 5. Selenium-RC Server's start-up

    is required.

    5. Does not Requires Selenium-RC Server

    to be running. 6. Access to headless HTMLUnit

    can allow really fast tests. Selenium: Bugs are found by tests, not by automation Presentation

    Agenda 0. What is Selenium? 1. Comparison:

    Selenium RC vs WebDriver 2. Interface WebDriver.

    Tips, Hacks & Hidden Features 3. Migrating from

    Selenium RC to WebDriver The most important Commands

    and Operations... Also, you can simulate pressing the arrow keys by using the Keys class:

    element.sendKeys("s", Keys.ARROW_DOWN);

    It is possible to call sendKeys on any element, which makes it possible to test keyboard shortcuts

    such as those used in GMail. WebElement loginElement =

    driver.findElement(By.name("AuthForm[loginOrEmail]"));

    loginElement.clear();

  • 5/24/2018 Selenium Jargon

    9/401

    loginElement.sendKeys("[email protected]");

    driver.findElement(By.xpath("//input[contains(@value,'Sign in')]")).click(); Evgeny Tkachenko

    Senior Software Automation Testing Engineer Evgeny Tkachenko Senior Software Automation

    Testing Engineer [email protected] our blog: http://www.innovatesting.info/ How to

    migrate to WebDriver ? Just "to Cut off" //Get the screen sizejava.awt.Dimension screenSize =

    Toolkit.getDefaultToolkit().getScreenSize();

    //Define the desired size

    Dimension maxWindowSize =

    new Dimension(screenSize.width -4, screenSize.height-4);

    //Set the desired size

    WebDriver.Window window = driver.manage().window();

    window.setSize(maxWindowSize); WebDriver. Hidden Features. Maximize the window Just

    start to use WebDriver API. But you need to rework all your methods in one massive push...

    Selenium 1, bye-bye! WebDriver. Hidden Features. Use WebDriver-Backed Selenium-RC... The

    Java version of WebDriver provides an implementation of the Selenium-RC API.

    This means that you can use the underlying WebDriver technology using the Selenium-RC API.

    File profileDir = new File("SeleniumProf");

    FirefoxProfile firefoxProfile = new FirefoxProfile(profileDir);

    WebDriver driver = new FirefoxDriver(firefoxProfile); WebDrivers API is more Object

    Oriented than the original Selenium RC API. Setting the path to Firefox You have write this line

    before opening the browser System.setProperty("webdriver.firefox.bin","pathtofirefox.exe");

    WebDriver (Selenium 2.0) is the merging of the Selenium and WebDriver projects.

    RemoteWebDriver

    Taking a Screenshot //Start Selenium Server with Java Code

    RemoteControlConfiguration rcc = new RemoteControlConfiguration();

    rcc.setTrustAllSSLCertificates(true);

    SeleniumServer seleniumServer = new SeleniumServer(rcc);

    if (!seleniumServer.getServer().isStarted())

    {

    seleniumServer.start()}

    // customize your capabilities here

    DesiredCapabilities capabilities = DesiredCapabilities.firefox();

    ...

  • 5/24/2018 Selenium Jargon

    10/401

    // RemoteWebDriver does not implement the TakesScreenshot class

    // but We can create MyRemoteWebDriver by extending RemoteWebDriver

    // and implementing TakesScreenshot interface.

    driver = new MyRemoteWebDriver(new URL("http://machineIP:port/wd/hub"),capabilities);

    class MyRemoteWebDriver extends RemoteWebDriver implements TakesScreenshot {

    ...

    public MyRemoteWebDriver(URL remoteAddress,

    Capabilities desiredCapabilities) {

    super(remoteAddress, desiredCapabilities);

    }

    @Override

    public X getScreenshotAs(OutputType target) throws WebDriverException {

    if ((Boolean) getCapabilities().getCapability(CapabilityType.TAKES_SCREENSHOT)) {

    String base64Str = execute(DriverCommand.SCREENSHOT).getValue().toString();

    return target.convertFromBase64Png(base64Str);

    }

    return null;

    }

    }

    --------------------------------------------------------------------------------------------

    Automation Framework Design Structure.

    Perquisites for automation frame work.

    What are all needed for designing automation framework?

    Folder Structure for Automation frame work.

  • 5/24/2018 Selenium Jargon

    11/401

    1. Create a Java Project and add the library files into JRE System Library.

    The folder structure will be.

    a. Test Util.Javab. Test Data

    c. OR. Properties.

    d. Tests(or Classes).java

    e. Driver Script. Java

    f. Library files

    g. testing.xml

    h. Screen shots.

    i. Test output

    Now we will discuss about the frame work how to design and how to

    work with framework.

    Before that we will discuss about each and every packages (Each

    script file).

    a. Library Files which need to add...

    http://2.bp.blogspot.com/-VqP2B_w_i-8/UyGZ4sIyH9I/AAAAAAAAC7k/-21v2eGgF8k/s1600/1.pnghttp://2.bp.blogspot.com/-6q0Ig_zG1kY/UyGZcihOzGI/AAAAAAAAC7c/ZKAs_SegUN4/s1600/1.png
  • 5/24/2018 Selenium Jargon

    12/401

    Note: No need to download each and every jar. Just download the

    below jars which contains all from the below given link.

    Link : Seleniumhq.org/Download/

    b. Test Util.java:

    --- This package is mainly deals with utilities. like..

    Initialize.

    get Object.

    waitForElementPopulate

    WaitForElementPresent waitFor5Seconds

    typeData

    getExcelData

    take Screenshot

    test Login

    selectFromDropdown

    http://docs.seleniumhq.org/download/http://docs.seleniumhq.org/download/http://4.bp.blogspot.com/-Nypkv3AbDlA/UyGaF_UXO1I/AAAAAAAAC7s/CPne04vdKP8/s1600/2.pnghttp://docs.seleniumhq.org/download/
  • 5/24/2018 Selenium Jargon

    13/401

    Initialize. In initialization we need to read the property file data. Like below

    publicstaticvoidintialize() throwsIOException {

    try{props= newProperties();fis= newFileInputStream(System.getProperty("user.dir")+"\\src\\

    OR.properties");System.out.println(fis);props.load(fis);

    } catch(FileNotFoundException e) {e.printStackTrace();

    }

    }

    ****** here we have to create an instance for properties and read

    through file input stream and load the props file .

    get Object.

    Get object concept will use in the test scripts. LikepublicWebElement getObject(String xpathkey) throwsIOException {

    try{return driver.findElement(By.xpath(props.getProperty(xpa

    thkey)));} catch(Throwable t) {

    System.out.println("error:\t"+ xpathkey);

    returnnull;}

    }

    Here we have to use this method as

    getObject(Xpath given in the property file).click();

    getObject(Xpath).getTitle();

    getObject(Xpath).getText();...etc...in the test scripts

    waitForElementPopulate : this method will use in case of anypublicvoidwaitForElementPopulate(String xpathkey) throwsException

    {

    inti = 0;String expdata = null;while(i

  • 5/24/2018 Selenium Jargon

    14/401

    Thread.sleep(2000L);expdata = getObject(xpathkey).getText().trim();System.out.println(expdata);if(expdata != null) {

    System.out.println(expdata);break;

    } else{Thread.sleep(500L);i++;

    }}

    }

    Ex: waitForElementPopulate(xpathkey);

    WaitForElementPresent: It will wait for Element present in the Web page. Until

    the web element present in the web page it will wait.publicWebElement WaitForElementPresent(String xpathkey) throwsException {

    WebElement present = null;inti = 0;while(i

  • 5/24/2018 Selenium Jargon

    15/401

    publicvoidtypeData(String xpathkey, String value) throwsException {

    try{getObject(xpathkey).sendKeys(value);

    } catch(Exception t) {t.printStackTrace();

    }}

    Ex: TypeData(Xpath from propertyfile,Value you want to enter into text field);

    GetExcelData(Xpath,SheetName,TableName1,Tablename2);

    This method will read the excel data and send the data into text

    fields in the application.publicString[][] getExcelData(String xlPath, String shtName, String tbName, StringtbName1)throwsException{

    String[][] tabArray=null;Workbook workbk = Workbook.getWorkbook(newFile(xlPath));Sheet sht = workbk.getSheet(shtName);intsRow,sCol, eRow, eCol,ci,cj;Cell tableStart=sht.findCell(tbName);sRow=tableStart.getRow(); sCol=tableStart.getColumn(); Cell tableEnd= sht.findCell(tbName1);eRow=tableEnd.getRow(); eCol=tableEnd.getColumn(); System.out.println("startRow="+sRow+", endRow="+eRow+",

    "+ "startCol="+sCol+", endCol="+eCol);tabArray=newString[eRow-sRow-1][eCol-sCol-1];ci=0;for(inti=sRow+1;i

  • 5/24/2018 Selenium Jargon

    16/401

    Ex: takeScreenShot(Filename,folder,Modname);

    TestLogin: this method useful to direct login to the application.

    publicvoidtestLogin(String UserName, String Password) throwsException {

    if(getObject("login.username.label")!= null&& getObject("login.pwd.label") != null) {

    typeData("en.distributor.UName", UserName);typeData("en.distributor.Pwd", Password);getObject("en.distributor.LgBtn").submit();System.out.println("Clicked on Login button");waitFor5Seconds();

    }

    }

    Ex: testLogin(UserName, Password); or testLogin(Admin, 111);

    SelectfromDropDown: this will select an option from drop down list.

    publicvoidselectFromDropdown(String xpathkey, String value) throwsException{/*waitFor5Seconds();*/ WebElement table6 = getObject(xpathkey);List tds6 = table6.findElements(By.tagName("option"));for(WebElement option : tds6) {

    if(option.getText().equals(value)) {option.click();

    }

    }

    So far we discussed about TestUtil file....

    Now we are going to discuss about the test data.

    2. Test Data :

    This is an excel file which contains Test data to test the

    application. Please find the sample test data file.

    GetExcelData(Location,SheetName,TableName1,Tablename2);

  • 5/24/2018 Selenium Jargon

    17/401

    3. OR. Properties.

    This is very crucial concept need to concentrate . because the

    properties are stored in the Property file. I will show you the sample.

    http://3.bp.blogspot.com/-23LpQsJy4bk/UyGae01CxMI/AAAAAAAAC78/W3uSj5owUoI/s1600/4.pnghttp://1.bp.blogspot.com/-Sbsxr98g1kg/UyGaa1bSYbI/AAAAAAAAC70/Hbl7M4HnCiE/s1600/3.png
  • 5/24/2018 Selenium Jargon

    18/401

    4. Tests(.Java files)

    We will check with sample script for Gmail Login.packageGmail;import org.openqa.selenium.firefox.FirefoxDriver;

    import org.testng.annotations.BeforeClass;import org.testng.annotations.DataProvider;import org.testng.annotations.Test;importTestUtil.TestUtil;publicclassGmailLogin extendsTestUtil{

    publicString location= "path of Xls file";publicString sheetname1= "GmailLogin";publicString Baseurl= "http://mail.google.com" ;@BeforeClasspublicvoidsetUp(){

    driver= newFirefoxDriver();driver.manage().window().maximize();

    driver.get(Baseurl);}@Test(dataProvider="dp")publicvoidGLogin(String UserName,String Password) throwsException{

    // enter the username and password.testLogin(UserName, Password);waitFor5Seconds();

    if(getObject("login.login_Btn")!=null){WaitForElementPresent("login.login_Btn");//Click on login buttongetObject("login.login_Btn").click();

    }else{takeScreenShot("GmailLogin","Gmailtest", "Gmail");}

    }

    @DataProvider(name = "dp")publicObject[][] createData() throwsException {

    Object[][] retObjArr = getExcelData(location, sheetname1,"GmailLogin", "GmailLogout");

    return(retObjArr);}}

    5. TestNg.xml

  • 5/24/2018 Selenium Jargon

    19/401

    ----------------------------------------------------------------------------------------1. I want to run all the tests in sequence.

    I added the preserve-order parameter in the suite. The tests run in the

    order we specified.

    2. I want to run the tests in multiple browser ? show me with code and xml

    file.

    Ans:

    MULTI BROWSER TESTING USING SELENIUM TESTNG

    This Section describes how to run your Test cases on different browsers.

    Few Simple steps Using TestNG :)

    Step 1: Create your Script. Using TestNG annotations. Define parameters

    (using @Parameters) for taking input value i.e, which browser should be used

    for Running the Test

    Step 2: Create a TestNG XML for running your script

    http://1.bp.blogspot.com/-FToN-tSTmO4/UyGaiUN1naI/AAAAAAAAC8E/eAqGxU62Gao/s1600/5.png
  • 5/24/2018 Selenium Jargon

    20/401

    Step 3: Configure the TestNG XML for passing parameters i.e, to tell which

    browser should be used for Running the Test

    Step 4: Run the TestNG XML which can pass the appropriate browser name tothe Script such that the Test Case is executed in a specified browser

    Programatically this can be Done as follows:

    Step 1:

    packageatu.multibrowser;

    importorg.openqa.selenium.By;

    import org.openqa.selenium.WebDriver;

    import org.openqa.selenium.chrome.ChromeDriver;

    import org.openqa.selenium.firefox.FirefoxDriver;

    import org.openqa.selenium.ie.InternetExplorerDriver;

    import org.testng.annotations.AfterClass;

    import org.testng.annotations.BeforeClass;

    import org.testng.annotations.Parameters;

    import org.testng.annotations.Test;

    publicclassMultiBrowserTest {

    privateWebDriver driver;// Configure for multi browser drivers

    @Parameters("browser")

    @BeforeClass

    publicvoidbeforeTest(String browser) {

    if(browser.equalsIgnoreCase("firefox")) {

    driver= newFirefoxDriver();

    } elseif(browser.equalsIgnoreCase("chrome")) {

    // Set Path for the executable file

    System.setProperty("webdriver.chrome.driver" ,

    "D:\\chromedriver.exe");driver= newChromeDriver();

    } elseif(browser.equalsIgnoreCase("ie")) {

    // Set Path for the executable file

    System.setProperty("webdriver.ie.driver", "D:\\IEDriverServer.

    exe");

    driver= newInternetExplorerDriver();

  • 5/24/2018 Selenium Jargon

    21/401

    } else{

    thrownewIllegalArgumentException("The Browser Type is

    Undefined");

    }

    // Open App

    driver.get("http://demo.opensourcecms.com/wordpress/wp-login.php");

    }

    @Test

    publicvoidlogin() throwsInterruptedException {

    // Enter UserName

    driver.findElement(By.id("user_login")).clear();

    driver.findElement(By.id("user_login")).sendKeys("admin");

    // Enter Password

    driver.findElement(By.id("user_pass")).clear();

    driver.findElement(By.id("user_pass")).sendKeys("demo123");// Click on Submit button

    driver.findElement(By.id("wp-submit")).submit();

    }

    @AfterClass

    publicvoidafterTest() {

    try{

    driver.quit();

    } catch(Exception e) {

    driver= null;

    }}

    }

    Step 2 & Step 3: The below XML is configured to run the Test Case in Firefox,

    Chrome and IE browser in sequential manner

  • 5/24/2018 Selenium Jargon

    22/401

    ------------------------------------------------------------HOW TO SEND AN EMAIL USING SELENIUM1.public class emil{

    public static String file[] = {System.getProperty("user.dir")+"//test-output//index.html"};

    public static StringtoAddress[]={"[email protected]","[email protected]

    om","[email protected]"};

    public static void main(String[] args) throws Exception{

    Mail();}public static void Mail() throws Exception{

    if(EmailSender.SendMail("[email protected]", "nani@11210","Automation Scripts Report for Australia Market", toAddress, file)){

    System.out.println("Email has been sent");// logger.info("Email has been sent");

    }else{//logger.info("Error occured in sending email");

    }}

    }

    http://simpleseleniumwithjava.blogspot.in/2014/02/how-to-send-email-using-selenium.htmlhttp://simpleseleniumwithjava.blogspot.in/2014/02/how-to-send-email-using-selenium.htmlhttp://simpleseleniumwithjava.blogspot.in/2014/02/how-to-send-email-using-selenium.htmlhttp://simpleseleniumwithjava.blogspot.in/2014/02/how-to-send-email-using-selenium.htmlhttp://simpleseleniumwithjava.blogspot.in/2014/02/how-to-send-email-using-selenium.htmlhttp://simpleseleniumwithjava.blogspot.in/2014/02/how-to-send-email-using-selenium.htmlhttp://simpleseleniumwithjava.blogspot.in/2014/02/how-to-send-email-using-selenium.htmlhttp://simpleseleniumwithjava.blogspot.in/2014/02/how-to-send-email-using-selenium.htmlhttp://simpleseleniumwithjava.blogspot.in/2014/02/how-to-send-email-using-selenium.htmlhttp://simpleseleniumwithjava.blogspot.in/2014/02/how-to-send-email-using-selenium.html
  • 5/24/2018 Selenium Jargon

    23/401

    2. package Enroll;

    import java.io.IOException;import java.util.Properties;

    import javax.mail.Authenticator;import javax.mail.MessagingException;import javax.mail.Multipart;import javax.mail.PasswordAuthentication;import javax.mail.Session;import javax.mail.Transport;import javax.mail.internet.InternetAddress;import javax.mail.internet.MimeBodyPart;import javax.mail.internet.MimeMessage;import javax.mail.internet.MimeMessage.RecipientType;import javax.mail.internet.MimeMultipart;

    public class EmailSender extends Authenticator {

    public static Properties props =null;public String user=null;public String pw=null;public EmailSender(String username,String password){

    super();this.user = username;this.pw = password;

    }

    public PasswordAuthentication getPasswordAuthentication(){

    return new PasswordAuthentication(user, pw);}public static boolean SendMail(String fromMail,String password,String

    message,String toMail[],String[] attachFiles) throws Exception{

    String host="smtp.gmail.com";props= System.getProperties();props.put("mail.smtp.starttls.enable", "true");

    props.put("mail.smtp.host", host);props.put("mail.smtp.user", fromMail);props.put("mail.smtp.password", password);props.put("mail.smtp.port", "587");props.put("mail.smtp.auth", "true");props.put("mail.smtp.starttls.enable", "true");

  • 5/24/2018 Selenium Jargon

    24/401

    Session session = Session.getInstance(props,new EmailSender(fromMail,password));

    MimeMessage mimeMessage=new MimeMessage(session);try{

    mimeMessage.setFrom(new InternetAddress(fromMail));

    //now get the address of reciepientInternetAddress[] toAddress=new InternetAddress[toMail.length];for(int i=0;i 0) {for (String filePath : attachFiles) {

    MimeBodyPart attachPart = new MimeBodyPart();

    try {attachPart.attachFile(filePath);

  • 5/24/2018 Selenium Jargon

    25/401

    } catch (IOException ex) {ex.printStackTrace();

    }System.out.println("Attachment has been added");multipart.addBodyPart(attachPart);

    }}

    /*mimeMessage.setText(message);*/mimeMessage.setContent(multipart);Transport transport=session.getTransport("smtp");transport.connect(host, fromMail, password);Transport.send(mimeMessage, mimeMessage.getAllRecipients());

    transport.close();return true;

    }catch(MessagingException me){me.printStackTrace();

    }return false;

    }}

    ------------------------------------------------------------------------------------RCPRACTICE SCRIPTSXpath

    import com.thoughtworks.selenium.DefaultSelenium;

    public class Xpath {

    /*** @param args*/

    public static void main(String[] args) {

    // TODO Auto-generated method stubDefaultSelenium selenium = new DefaultSelenium("localhost", 6666,"*iehta", "http://");

    selenium.start();selenium.open("http://mail.in.com");selenium.windowMaximize();

    selenium.type("xpath=/html/body/div[1]/div[2]/div/table/tbody/tr[2]/td[3]/form/div/div[1]/p[3]/input[@id='f_id']","username");

  • 5/24/2018 Selenium Jargon

    26/401

    selenium.type("xpath=/html/body/div[1]/div[2]/div/table/tbody/tr[2]/td[3]/form/div/div[1]/p[5]/input[@id='f_pwd']","password");

    }

    }

    2. Validation:

    import com.thoughtworks.selenium.DefaultSelenium;

    public class Validation {

    public static DefaultSelenium selenium=new DefaultSelenium("localhost",6666,"*iehta","http://");

    public static String Bodytext(){selenium.start();selenium.open("http://google.com");selenium.windowMaximize();

    if(selenium.isTextPresent("Nag")){System.out.println("Already checked");}else{selenium.select("", "label=one");//selenium.type("q", "selenium");selenium.check("chkbox");

    //System.out.println("Alert is not available");}

    selenium.click("btnG");return "pass";

    }public static void main(String[] args) {

    // TODO Auto-generated method stub

    Bodytext();

    }

    }

    3. Test DB

  • 5/24/2018 Selenium Jargon

    27/401

    import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;

    public class testdb {public static Connection connection;public static Statement statement;public static ResultSet resultSet;public static void main(String[] args) {

    // TODO Auto-generated method stubtry {Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");connection = DriverManager.getConnection("jdbc:sqlserver://servername;instance=SQLEXPRESS;databaseName=ccdata;","Username",

    "Password");statement = connection.createStatement();

    resultSet = statement.executeQuery("select * from emp");while (resultSet.next()) {System.out.println("EMPLOYEE NAME:" + resultSet.getString("emp name"));System.out.println("EMPLOYEE ID:" + resultSet.getString("emp ID"));}} catch (Exception e) {e.printStackTrace();}

    }

    }

    4. TEST

    import com.thoughtworks.selenium.DefaultSelenium;

    public class Test {

    public static DefaultSelenium selenium = new DefaultSelenium("localhost",6666, "*iehta", "http://");

    public static String fun1() throws Exception

    {try{selenium.start();selenium.open("//google.co.in");Thread.sleep(30000);selenium.type("q", "selenium");selenium.click("btnG");

  • 5/24/2018 Selenium Jargon

    28/401

    }catch(Exception e){

    }

    return "pass";}

    public static void main(String[] args) throws Exception

    {// TODO Auto-generated method stubfun1();

    }

    }

    5. Sync:

    import com.thoughtworks.selenium.DefaultSelenium;

    public class Sync {

    /*** @param args*/

    public static String google() throws Exception{DefaultSelenium selenium=new DefaultSelenium("localhost",6666,"*iehta","http://");selenium.start();selenium.open("http://mail.in.com");selenium.windowMaximize();selenium.type("f_id", "seleniumforum_Nageswar");selenium.type("f_pwd", "selenium");

    // selenium.setTimeout("100000");selenium.click("//input[@value='' and @type='submit']");//Thread.sleep(10000);

    selenium.waitForPageToLoad("130000");selenium.click("link=Sign out");selenium.waitForPageToLoad("130000");selenium.chooseCancelOnNextConfirmation();selenium.chooseOkOnNextConfirmation();return "pass";

    }public static void main(String[] args) throws Exception{

  • 5/24/2018 Selenium Jargon

    29/401

    // TODO Auto-generated method stubgoogle();

    }

    }

    6. Reusability

    import java.io.FileInputStream;

    import jxl.Sheet;import jxl.Workbook;

    import com.thoughtworks.selenium.DefaultSelenium;public class ReusableScript {public static DefaultSelenium selenium = new DefaultSelenium("localhost",

    6666, "*iehta", "http://");

    public static String gmail() throws Exception {selenium.start();selenium.open("http://www.gmail.com");selenium.windowMaximize();Thread.sleep(2000);selenium.click("link=Create an account ");selenium.waitForPageToLoad("30000");return "pass";

    }public static String Register() throws Exception {

    FileInputStream fi = new FileInputStream("D:\\Framework\\TestData\\Register.xls");

    Workbook w = Workbook.getWorkbook(fi);Sheet s = w.getSheet(0);for (int i = 1; i < s.getRows(); i++) {if (!s.getCell(3, i).getContents().equals("")) {if (s.getCell(2, i).getContents().contains("Text")) {if (selenium

    .isElementPresent(s.getCell(0, i).getContents())) {selenium.type(s.getCell(0, i).getContents(), s.getCell(3, i).getContents());

    }} else if (s.getCell(2, i).getContents().contains("Combo")) {

    if (selenium.isElementPresent(s.getCell(0, i).getContents())) {selenium.select(s.getCell(0, i).getContents(), "label="+ s.getCell(3, i).getContents());

    }} else if (s.getCell(2, i).getContents().contains("chkbox")) {if (selenium

    .isElementPresent(s.getCell(0, i).getContents())) {selenium.click(s.getCell(0, i).getContents());

  • 5/24/2018 Selenium Jargon

    30/401

    }

    } else if (s.getCell(2, i).getContents().contains("Radio")) {if (selenium

    .isElementPresent(s.getCell(0, i).getContents())) {selenium.click(s.getCell(0, i).getContents());

    }

    }else if (s.getCell(2, i).getContents().contains("Button")) {if (selenium

    .isElementPresent(s.getCell(0, i).getContents())) {selenium.click(s.getCell(0, i).getContents());

    }}

    }

    }

    return "pass";}

    public static void main(String[] args) throws Exception {// TODO Auto-generated method stubgmail();Register();

    }

    }

    7. Keys Events

    import java.awt.event.KeyEvent;public class KeyEvents extends DriverScript{public static void main(String[] args) {

    // TODO Auto-generated method stubselenium.start();selenium.open("http://www.google.com");selenium.windowMaximize();

    selenium.setCursorPosition("q", "1");selenium.keyDownNative(Integer.toString(KeyEvent.VK_SHIFT));selenium.keyPressNative(String.valueOf(KeyEvent.VK_D));selenium.keyUpNative(Integer.toString(KeyEvent.VK_SHIFT));//selenium.keyDownNative(Integer.toString(KeyEvent.VK_SHIFT));selenium.keyPressNative(Integer.toString(KeyEvent.VK_SEMICOLON));selenium.keyUpNative(Integer.toString(KeyEvent.VK_SHIFT));selenium.keyPressNative(Integer.toString(KeyEvent.VK_SLASH));selenium.keyPressNative(String.valueOf(KeyEvent.VK_S));

  • 5/24/2018 Selenium Jargon

    31/401

    selenium.keyPressNative(String.valueOf(KeyEvent.VK_E));selenium.keyPressNative(String.valueOf(KeyEvent.VK_L));selenium.keyPressNative(String.valueOf(KeyEvent.VK_E));selenium.keyPressNative(String.valueOf(KeyEvent.VK_N));

    }

    }

    8. Get Data

    import com.thoughtworks.selenium.DefaultSelenium;

    public class GetData {

    public static DefaultSelenium selenium=new DefaultSelenium("localhost",6666,"*iehta","http://");

    public static String Bodytext(){selenium.start();selenium.open("http://google.com");selenium.windowMaximize();selenium.type("q", "abc");String str=selenium.getBodyText();//String str=selenium.getHtmlSource();String link[]=selenium.getAllWindowNames();

    System.out.println("The links are"+link.length);System.out.println("The links are"+link[0]);

    selenium.captureScreenshot("D:\\Selenium\\page.jpg");return "pass";

    }public static String Dynamic(){selenium.click("add1");String windname[]=selenium.getAllWindowNames();String windid[]=selenium.getAllWindowIds();String windtitle[]=selenium.getAllWindowTitles();selenium.getValue("");

    System.out.println("The window names are"+windname.length);selenium.selectWindow(windname[1]);selenium.click("ok");

    return "pass";}public static void main(String[] args) {

    // TODO Auto-generated method stub

  • 5/24/2018 Selenium Jargon

    32/401

    Bodytext();}

    }

    9. EXCEL Login

    import java.io.FileInputStream;import java.io.FileOutputStream;

    import com.thoughtworks.selenium.DefaultSelenium;

    import jxl.Sheet;import jxl.Workbook;import jxl.write.Label;import jxl.write.WritableSheet;import jxl.write.WritableWorkbook;

    public class Export_Login {public static String status = "pass";public static String export() throws Exception {

    FileInputStream file = new FileInputStream("D:\\Framework\\TestData\\login_Data.xls");

    Workbook w = Workbook.getWorkbook(file);Sheet s = w.getSheet(0);FileOutputStream fo = new FileOutputStream("D:\\Framework\\Results\\Loginout.xls");

    WritableWorkbook wwb = Workbook.createWorkbook(fo);WritableSheet ws = wwb.createSheet("login", 0);String a[][] = new String[s.getRows()][s.getColumns()];DefaultSelenium selenium = new DefaultSelenium("localhost", 6666,"*iehta", "http://");

    selenium.start();selenium.open("http://mail.in.com");selenium.windowMaximize();

    for (int i = 0; i < s.getRows(); i++) {selenium.type("f_id", s.getCell(0, i).getContents());selenium.type("f_pwd", s.getCell(1, i).getContents());selenium.click("//input[@value='' and @type='submit']");

    Thread.sleep(10000);if (selenium.isElementPresent("link=Sign out")) {selenium.click("link=Sign out");Thread.sleep(6000);status = "Pass";System.out.println("if loop" + status);} else {status = "Fail";System.out.println("else loop" + status);

  • 5/24/2018 Selenium Jargon

    33/401

    }for (int j = 0; j < s.getColumns(); j++) {

    a[i][j] = s.getCell(j, i).getContents();Label l = new Label(j, i, a[i][j]);Label Res = new Label(2, 0, "Result");Label rs = new Label(2, i, status);ws.addCell(l);ws.addCell(Res);ws.addCell(rs);System.out.println("The contents are" + a[i][j]);}selenium.open("http://mail.in.com");}wwb.write();wwb.close();return "pass";

    }

    public static void main(String[] args) throws Exception {// TODO Auto-generated method stub

    export();}

    }10.EXCEL

    import java.io.FileOutputStream;import jxl.Workbook;import jxl.write.Label;import jxl.write.WritableSheet;import jxl.write.WritableWorkbook;public class Export_Excel {public static String export() throws Exception{FileOutputStream fo=new FileOutputStream("D:\\Framework\\Results\\Result_export.xls");WritableWorkbook wwb=Workbook.createWorkbook(fo);WritableSheet ws=wwb.createSheet("Res", 0);Label l=new Label(1,0,"Nagesh");

    Label l1=new Label(0,0,"Rao");Label l2=new Label(2,3,"Duplicate");Label l3=new Label(0,0,"Minq");ws.addCell(l);ws.addCell(l1);ws.addCell(l2);wwb.write();wwb.close();

  • 5/24/2018 Selenium Jargon

    34/401

    return "pass";}public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stubexport() ;

    }

    }

    11. Execute Test Case

    public class Execute_Testcases {public static void main(String[] args) throws Exception

    {DriverScript.Set_Execution_sheet("D:\\Framework\\Environment\\url.xls");

    DriverScript.Execute("D:\\Framework\\MainScript\\testcases.xls");

    }

    }

    12. EXcel

    import java.io.FileInputStream;import jxl.Sheet;import jxl.Workbook;import com.thoughtworks.selenium.DefaultSelenium;public class Excel extends DriverScript{public static String login_Excel() throws Exception{//DefaultSelenium selenium=new DefaultSelenium("localhost",6666,"*iehta","http://");FileInputStream file=new FileInputStream("D:\\Framework\\TestData\\login_Data.xls");Workbook w=Workbook.getWorkbook(file);Sheet s=w.getSheet(0);FileInputStream fi=new FileInputStream("D:\\Framework\\ObjectRepository\\login_OR.xls");Workbook w1=Workbook.getWorkbook(fi);Sheet s1=w1.getSheet(0);//Sheet s=w.getSheet("Sheet1");

    /*selenium.start();selenium.open("http://mail.in.com");selenium.windowMaximize();*/

    // for (int i = 1; i < s.getRows(); i++) {

    selenium.type(s1.getCell(0, 1).getContents(), s.getCell(0, 1).getContents());selenium.type(s1.getCell(1, 1).getContents(), s.getCell(1, 1).getContents());//System.out.println("the value of i"+i);

  • 5/24/2018 Selenium Jargon

    35/401

    //}

    // selenium.setTimeout("100000");selenium.click(s1.getCell(2, 1).getContents());

    return "pass";}public static String close(){selenium.close();return "pass";

    }public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stub//login_Excel();

    }

    }

    13. Driver Script

    import java.io.FileInputStream;import java.lang.reflect.Method;

    import com.thoughtworks.selenium.DefaultSelenium;

    import jxl.Sheet;import jxl.Workbook;import jxl.write.Label;import jxl.write.WritableSheet;import jxl.write.WritableWorkbook;public class DriverScript{

    static String className = null;public static String urlpath=null;public static int rs=1;public static String result=null;public static DefaultSelenium selenium=new

    DefaultSelenium("localhost",6666,"*iehta","http://");public static boolean Set_Execution_sheet(String strPath) throws Exception

    {String urlpath=strPath;FileInputStream file= new FileInputStream(urlpath);Workbook wb=Workbook.getWorkbook(file);Sheet sh=wb.getSheet(0);selenium.start();selenium.open(sh.getCell(1, 1).getContents());selenium.windowMaximize();return true;

  • 5/24/2018 Selenium Jargon

    36/401

    }public static boolean Execute(String str) throws Exception{FileInputStream file=new FileInputStream(str);Workbook wb=Workbook.getWorkbook(file);Sheet s=wb.getSheet(0);for(int iRownum=1;iRownum1;i--)

    {if(!(s.getCell(5, i).getContents()).contentEquals("")){

    className=s.getCell(5, i).getContents();break;

    }}

    }String functioncall = s.getCell(6, iRownum).getContents();int inumofparameters=0;Object ret = null;String methodName = functioncall.substring(0,functioncall.indexOf("("));String strparameters =

    functioncall.substring(functioncall.indexOf("(")+1,functioncall.indexOf(")"));String strparameterslist[]=strparameters.split(",");inumofparameters= strparameterslist.length;selenium.captureScreenshot(ScreenShotPath);if(strparameters.length()==0){inumofparameters=0;

    }Class c = Class.forName(className);if(inumofparameters!=0){

    Class cParameters[]=new Class[inumofparameters];

    for(int temp=0;temp

  • 5/24/2018 Selenium Jargon

    37/401

    arglist[iparameternum] = new String(strparameterslist[iparameternum]);}ret = m.invoke(ob,arglist);}else{

    Method m = c.getMethod(methodName,null);Object ob = c.newInstance();ret = m.invoke(ob,null);System.out.println("return value:"+ ret);

    }rs++;

    }catch(Exception e){selenium.captureScreenshot(ScreenShotPath);e.printStackTrace();

    }}

    return true;

    }}

    14. DOM

    public class DOM extends DriverScript{public static String click(String str){String index=selenium.getEval("varx=selenium.browserbot.getCurrentWindow().document.getElementsByTagName(\"a\");for(vari=0;i

  • 5/24/2018 Selenium Jargon

    38/401

    import java.util.*;

    public class CurrentTime{public static void main(String[] args){

    Calendar calendar = new GregorianCalendar();String am_pm;int hour = calendar.get(Calendar.HOUR);int minute = calendar.get(Calendar.MINUTE);int second = calendar.get(Calendar.SECOND);if(calendar.get(Calendar.AM_PM) == 0)

    am_pm = "AM";else

    am_pm = "PM";System.out.println("Current Time : " + hour + ":"

    + minute + ":" + second + " " + am_pm);}

    }

    16. Create Excel

    import java.io.FileOutputStream;import java.text.SimpleDateFormat;import java.util.Calendar;

    import jxl.Workbook;import jxl.write.Label;import jxl.write.WritableSheet;import jxl.write.WritableWorkbook;public class Create_Excel {public static String dateNow=null;public static void time(){

    Calendar currentDate = Calendar.getInstance();SimpleDateFormat formatter=new SimpleDateFormat("yyyyMMMdd_HHmmss");dateNow = formatter.format(currentDate.getTime());System.out.println("Now the date is :=> " + dateNow);

    }public static String excel() throws Exception{

    time();FileOutputStream fo=newFileOutputStream("E:\\Framework\\Results\\loginRes_"+dateNow+".xls");WritableWorkbook wwb=Workbook.createWorkbook(fo);WritableSheet ws=wwb.createSheet("LoginResults", 0);Label l=new Label(0,0,"Username");Label l1=new Label(1,0,"Password");Label l2=new Label(2,0,"Results");ws.addCell(l);

  • 5/24/2018 Selenium Jargon

    39/401

    ws.addCell(l1);ws.addCell(l2);wwb.write();wwb.close();

    return "Pass";}public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stubexcel();

    }

    }

    17. Create Excel 1

    import java.io.FileOutputStream;import java.text.SimpleDateFormat;

    import java.util.Calendar;

    import jxl.Workbook;import jxl.write.Label;import jxl.write.WritableSheet;import jxl.write.WritableWorkbook;public class Create_Excel1 {public static String dateNow=null;public static void time(){

    Calendar currentDate = Calendar.getInstance();SimpleDateFormat formatter=new SimpleDateFormat("yyyyMMMdd_HHmmss");dateNow = formatter.format(currentDate.getTime());System.out.println("Now the date is :=> " + dateNow);

    }public static String excel() throws Exception{time();FileOutputStream fo=new FileOutputStream("E:\\Framework\\Results\\loginres"+dateNow+".xls");WritableWorkbook wwb=Workbook.createWorkbook(fo);WritableSheet ws=wwb.createSheet("LoginResults", 0);

    Label lab=new Label(0,0,"Username");Label pw=new Label(1,0,"Password");Label rs=new Label(2,0,"Result");ws.addCell(lab);ws.addCell(pw);ws.addCell(rs);wwb.write();wwb.close();return "Pass";

  • 5/24/2018 Selenium Jargon

    40/401

    }public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stub

    excel();

    }

    }

    18. Data Base Script

    public class DataBaseTest {

    /*** @param args* @throws SQLException

    */public static void main(String[] args) throws SQLException {// TODO Auto-generated method stubConnection connection = null;ResultSet objResultSet=null;PreparedStatement objPreStmnt=null;try {DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());Stringurl="jdbc:microsoft:sqlserver://psdbs01\\psdbs01A:1717;DatabaseName=ARROW_0_4_5_0";connection=DriverManager.getConnection(url,"arrow_sqa","arrow_sqa");System.out.println(">>>>>>>>>Connected>>>>>>>>");

    String strQuery = "select case_id,workitemid,userid from workbasket where case_id=? andworkitemid=? and userid=?";

    //Assigning the QueryobjPreStmnt = connection.prepareStatement(strQuery);objPreStmnt.setInt(1,2026086);objPreStmnt.setInt(2,2000093);objPreStmnt.setInt(3,2000297);objResultSet = objPreStmnt.executeQuery(); //Executing the Querywhile (objResultSet.next()) {

    System.out.println(" case_id:"+objResultSet.getString("case_id"));System.out.println(" workitemid:"+objResultSet.getString("workitemid"));System.out.println(" userid:"+objResultSet.getString("userid"));}

    } catch (Exception e) {e.printStackTrace();}finally{objResultSet.close();

  • 5/24/2018 Selenium Jargon

    41/401

    objPreStmnt.close();connection.close();}

    }

    }

    19. Driver Script

    import java.io.FileInputStream;import java.io.FileOutputStream;import java.lang.reflect.Method;import com.thoughtworks.selenium.DefaultSelenium;

    import jxl.Sheet;import jxl.Workbook;import jxl.write.Label;import jxl.write.WritableSheet;import jxl.write.WritableWorkbook;public class DriverScript {

    static String className = null;public static int rs = 1;

    public static DefaultSelenium selenium = new DefaultSelenium("localhost",1212,"*firefox",

    "http://");public static boolean Set_Execution_sheet(String strPath) throws Exception {

    FileInputStream file = new FileInputStream(strPath);Workbook wb = Workbook.getWorkbook(file);Sheet sh = wb.getSheet(0);selenium.start();selenium.open(sh.getCell(1, 1).getContents());selenium.windowMaximize();return true;

    }public static boolean Execute(String str) throws Exception { //To take the data from Testcases.xls

    FileInputStream file = new FileInputStream(str);Workbook wb = Workbook.getWorkbook(file);

    Sheet s = wb.getSheet(0);//To create the out put Result file

    FileOutputStream fo=new

    FileOutputStream("E:\\Framework\\Results\\loginResults.xls");WritableWorkbook wwb=Workbook.createWorkbook(fo);WritableSheet ws=wwb.createSheet("LoginResults", 0);//Add a label 'Result'Label res=new Label(8,0,"Results");ws.addCell(res);

  • 5/24/2018 Selenium Jargon

    42/401

    //To take each row datafor (int i = 1; i

  • 5/24/2018 Selenium Jargon

    43/401

    import java.io.FileInputStream;import java.io.FileOutputStream;import jxl.Sheet;import jxl.Workbook;import jxl.write.Label;import jxl.write.WritableSheet;import jxl.write.WritableWorkbook;public class ExportInputdata_Step2 {public static String export() throws Exception{FileInputStream fi=new FileInputStream("E:\\Framework\\Testdata\\logindata.xls");

    Workbook w=Workbook.getWorkbook(fi);Sheet s=w.getSheet(0);

    FileOutputStream fo=new FileOutputStream("E:\\Framework\\Results\\loginResults.xls");WritableWorkbook wwb=Workbook.createWorkbook(fo);WritableSheet ws=wwb.createSheet("LoginResults", 0);for (int i = 0; i < s.getRows(); i++) {

    for (int j = 0; j < s.getColumns(); j++) {System.out.println(s.getCell(j, i).getContents());Label data=new Label(j,i,s.getCell(j, i).getContents());ws.addCell(data);}}Label res=new Label(2,0,"Results");ws.addCell(res);wwb.write();wwb.close();return "Pass";

    }public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stubexport();

    }

    }

    21. google Link1

    import com.thoughtworks.selenium.DefaultSelenium;public class Google_link1 {

    public static DefaultSelenium selenium;public static String str=null;public static void wait(String str) throws Exception{for (int i = 0; i < 30; i++) {if(selenium.isElementPresent(str)){Thread.sleep(1000);selenium.isVisible(str);

  • 5/24/2018 Selenium Jargon

    44/401

    break;}}

    }public static String openURL(){selenium=new DefaultSelenium("localhost",1213,str,"http://");selenium.start();selenium.setTimeout("1000000");selenium.open("http://www.google.co.in/");selenium.windowMaximize();

    return "Pass";}public static String hindi() throws Exception{try{

    selenium.click("link=Hindi");wait("link=English");selenium.click("link=English");Thread.sleep(6000);}catch(Exception e){e.printStackTrace();}

    return "Pass";}public static String bengali() throws Exception{selenium.click("link=Bengali");Thread.sleep(6000);selenium.click("link=English");Thread.sleep(6000);return "Pass";

    }public static String telugu() throws Exception{selenium.click("link=Telugu");Thread.sleep(6000);selenium.click("link=English");Thread.sleep(6000);return "Pass";

    }public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stubstr="*firefox";for (int i = 0; i < 2; i++) {openURL();hindi();bengali();telugu();

  • 5/24/2018 Selenium Jargon

    45/401

    }}

    }

    22. Google Link2

    import com.thoughtworks.selenium.DefaultSelenium;public class Google_link2 {private static DefaultSelenium selenium=newDefaultSelenium("localhost",1212,"*firefox","http://");public static String openURL(){selenium.start();selenium.open("http://www.google.co.in/");selenium.windowMaximize();

    return "Pass";}public static String Click_link(String str) throws Exception{selenium.click("link="+str);Thread.sleep(6000);selenium.click("link=English");Thread.sleep(6000);return "Pass";

    }public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stubopenURL();Click_link("Hindi");Click_link("Bengali");Click_link("Telugu");

    }

    }

    23. Google Search

    import com.thoughtworks.selenium.DefaultSelenium;

    public class GooglesSearch extends DriverScript{

    public static String gs(){//DefaultSelenium selenium=new DefaultSelenium("localhost",1212,"*firefox","http://");//selenium.start();//selenium.open("http://google.co.in");

  • 5/24/2018 Selenium Jargon

    46/401

    //selenium.windowMaximize();selenium.type("gbqfq", "Nagesh");selenium.click("gbqfb");

    return "Pass";}

    }

    24. JUNIT

    import com.thoughtworks.selenium.*;import org.junit.After;import org.junit.Before;import org.junit.Test;

    public class Junit extends SeleneseTestCase {@Beforepublic void setUp() throws Exception {

    selenium = new DefaultSelenium("localhost", 1212, "*chrome", "http://www.mail.in.com/");selenium.start();

    }

    @Testpublic void testUntitled() throws Exception {

    selenium.open("/");selenium.windowMaximize();selenium.click("css=input.registernowjgfjvku");selenium.waitForPageToLoad("30000");selenium.type("id=fname", "nagesh");selenium.select("id=day", "label=13");selenium.select("id=month", "label=Mar");selenium.select("id=year", "label=2000");selenium.type("id=username", "nagesh_2000");

    }

    @Afterpublic void tearDown() throws Exception {

    selenium.stop();}}

    25. Login_OR_TDimport java.io.FileInputStream;import jxl.Sheet;import jxl.Workbook;import com.thoughtworks.selenium.DefaultSelenium;

  • 5/24/2018 Selenium Jargon

    47/401

    public class Login_OR_TD {public static DefaultSelenium selenium=new DefaultSelenium("localhost",1212,"*firefox","http://");public static String openURL(){selenium.start();selenium.open("http://www.mail.in.com/");selenium.windowMaximize();return "Pass";

    }public static String login() throws Exception{FileInputStream fi=new FileInputStream("E:\\Framework\\Testdata\\logindata.xls");

    Workbook w=Workbook.getWorkbook(fi);Sheet s=w.getSheet(0);

    FileInputStream fi1=new FileInputStream("E:\\Framework\\Object Repository\\loginOR.xls");Workbook w1=Workbook.getWorkbook(fi1);Sheet s1=w1.getSheet("Sheet1");

    selenium.type(s1.getCell(0, 1).getContents(), s.getCell(0, 1).getContents());selenium.type(s1.getCell(1, 1).getContents(), s.getCell(1, 1).getContents());selenium.click(s1.getCell(2, 1).getContents());selenium.waitForPageToLoad("30000");return "Pass";

    }public static String logout(){

    selenium.click("link=");return "Pass";

    }public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stubopenURL();login();logout();

    }

    }

    26. Login Results

    import java.io.FileInputStream;import java.io.FileOutputStream;import com.thoughtworks.selenium.DefaultSelenium;import jxl.Sheet;import jxl.Workbook;import jxl.write.Label;

  • 5/24/2018 Selenium Jargon

    48/401

    import jxl.write.WritableSheet;import jxl.write.WritableWorkbook;public class Login_Results_Step3 {public static DefaultSelenium selenium=new DefaultSelenium("localhost",1212,"*firefox","http://");public static String login() throws Exception{//To take data from Input file

    FileInputStream fi=new FileInputStream("E:\\Framework\\Testdata\\logindata.xls");Workbook w=Workbook.getWorkbook(fi);Sheet s=w.getSheet(0);//To create the out put Result file

    FileOutputStream fo=new FileOutputStream("E:\\Framework\\Results\\loginResults.xls");WritableWorkbook wwb=Workbook.createWorkbook(fo);WritableSheet ws=wwb.createSheet("LoginResults", 0);//String declarationString str=null;//Launching the application

    selenium.start();selenium.open("http://www.mail.in.com/");selenium.windowMaximize();

    for (int i = 1; i < s.getRows(); i++) {//To login into the application by taking data from xlsselenium.type("f_id", s.getCell(0, i).getContents());selenium.type("f_pwd", s.getCell(1, i).getContents());selenium.click("css=input.signin");selenium.waitForPageToLoad("30000");//Validating the Sign out linkif(selenium.isElementPresent("link=Sign out")){selenium.click("link=Sign out");Thread.sleep(3000);str="Pass";}else{str="Fail";System.out.println("Sign out is not available");}// To get the home pageselenium.open("http://www.mail.in.com/");//Export the result into Result file

    Label result=new Label(2,i,str);ws.addCell(result);// To export input data into Result filefor (int j = 0; j < s.getColumns(); j++) {System.out.println(s.getCell(j, i).getContents());Label data=new Label(j,i,s.getCell(j, i).getContents());ws.addCell(data);}}

  • 5/24/2018 Selenium Jargon

    49/401

    // Adding labels in the Result fileLabel un=new Label(0,0,"Username");Label pw=new Label(1,0,"Password");Label res=new Label(2,0,"Results");ws.addCell(un);ws.addCell(pw);ws.addCell(res);wwb.write();wwb.close();return "Pass";

    }public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stublogin();

    }

    }

    27. Login ReTesting

    import java.io.FileInputStream;import jxl.Sheet;import jxl.Workbook;import com.thoughtworks.selenium.DefaultSelenium;public class Login_Retesting {public static DefaultSelenium selenium=new DefaultSelenium("localhost",1212,"*firefox","http://");public static String openURL(){selenium.start();selenium.open("http://www.mail.in.com/");selenium.windowMaximize();return "Pass";

    }public static String login() throws Exception{FileInputStream fi=new FileInputStream("E:\\Framework\\Testdata\\logindata.xls");

    Workbook w=Workbook.getWorkbook(fi);Sheet s=w.getSheet(0);

    FileInputStream fi1=new FileInputStream("E:\\Framework\\Object Repository\\loginOR.xls");Workbook w1=Workbook.getWorkbook(fi1);

    Sheet s1=w1.getSheet("Sheet1");for (int i = 1; i < s.getRows(); i++) {selenium.type(s1.getCell(0, 1).getContents(), s.getCell(0, i).getContents());Thread.sleep(1000);

    selenium.type(s1.getCell(1, 1).getContents(), s.getCell(1, i).getContents());}

    //selenium.click(s1.getCell(2, 1).getContents());//selenium.waitForPageToLoad("30000");

  • 5/24/2018 Selenium Jargon

    50/401

    return "Pass";}public static String logout(){

    selenium.click("link=");return "Pass";

    }public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stubopenURL();login();//logout();

    }

    }

    28. Mail Login

    public class Mail_Login extends DriverScript{//public static DefaultSelenium selenium=newDefaultSelenium("localhost",1212,"*firefox","http://");public static String openURL(){/*selenium.start();selenium.open("http://www.mail.in.com/");selenium.windowMaximize();*/return "Pass";

    }public static String login(){selenium.type("f_id", "mar1selenium");selenium.type("f_pwd", "selenium");selenium.click("css=input.signin");selenium.waitForPageToLoad("30000");return "Pass";

    }public static String logout(){if(selenium.isElementPresent("link=Sign out")){selenium.click("link=Sign out");System.out.println("Pass");}else{System.out.println("Fail");

  • 5/24/2018 Selenium Jargon

    51/401

    }

    return "Pass";

    }public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stub

    }

    }

    29. Mail Reg

    public class Mail_Reg extends Mail_Login{

    public static String reg() throws Exception{selenium.click("css=input.registernow");selenium.waitForPageToLoad("30000");selenium.type("fname", "Nagesh");selenium.select("day", "5");selenium.select("month", "Apr");selenium.select("id=year", "label=2001");selenium.type("id=username", "nagesh2001");selenium.type("id=password", "nagesh123");selenium.type("id=repassword", "nagesh123");selenium.type("id=altemail", "[email protected]");selenium.click("id=imageField");Thread.sleep(2000);selenium.click("id=imageField");selenium.select("mcountry", "India");

    return "Pass";}public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stubopenURL();

    reg();}

    }

    30. Spice Jet popup

  • 5/24/2018 Selenium Jargon

    52/401

    import com.thoughtworks.selenium.DefaultSelenium;

    public class Spicejet_Popup {

    public static DefaultSelenium selenium=new

    DefaultSelenium("localhost",1234,"*firefox","http://");

    public static void main(String[] args) throws Exception {

    // TODO Auto-generated method stub

    selenium.start();

    selenium.open("http://spicejet.com");

    selenium.windowMaximize();

    selenium.click("id=oneWayRadio");

    selenium.select("id=from1Select", "label=Hyderabad");

    selenium.select("id=to1Select", "label=Vizag");

    selenium.click("css=#to1Select > option[value=\"VTZ\"]");selenium.click("id=departDate1text");

    selenium.click("link=5");

    selenium.click("id=submitBtn");

    selenium.getConfirmation();

    Thread.sleep(10000);

    selenium.click("id=m1f1r1");

    selenium.click("id=converterButton");

    selenium.waitForPopUp("converter", "30000");

    selenium.selectWindow("name=converter");

    selenium.type("id=amountText", "100");selenium.select("name=convert_from", "label=US Dollar (USD)");

    selenium.select("name=convert_to", "label=Indian Rupee (INR)");

    Thread.sleep(2000);

    selenium.click("id=closeButton");

    Thread.sleep(2000);

    //selenium.waitForPageToLoad("30000");

    selenium.selectWindow("null");

    selenium.click("id=nextDayButton1");

    selenium.waitForPageToLoad("30000");

    }

    }

    31. Step 2

    import java.io.FileInputStream;

  • 5/24/2018 Selenium Jargon

    53/401

    import java.io.FileOutputStream;

    import jxl.Sheet;

    import jxl.Workbook;

    import jxl.write.Label