JSA Test Automation Framework
-
Upload
jaspal-aujla -
Category
Documents
-
view
100 -
download
4
Transcript of JSA Test Automation Framework
Selenium/Java based Hybrid Test
Automation Framework
Developer: - Jaspal Singh Aujla Email: - [email protected] LinkedIn: - https://nz.linkedin.com/in/jaspalsinghaujla
JSA Test Automation Framework Page 1
Explanation: -
This is a Hybrid Test Automation Framework, which is a combination of Data Driven, Keyword Driven and
Modular framework. It is based on Selenium WebDriver and Java Programming Language. This framework
fulfils the requirement of TDD, BDD, Live Documentation and Page Object test approaches.
Advantages of this framework: -
1. I have seen in the software test automation industry that automation engineers prefer to automate
positive scenarios only. As per my experience and approach, I prefer to automate each and every test
case of an application including positive as well as negative scenarios. This framework (mechanism) is
specially developed to cover maximum coverage of test automation.
2. I am very confident that this framework will take least time as compare to any software test
automation technique (framework) to automate any application and test cases.
3. Once this framework will be implemented in any organization then a Software Tester with training on
element identification and how this framework works can automate any application without write a
single line of code. I already developed important Methods with extent of exception handling which
are completely reusable. A Software Tester just need to use these Methods (Keywords) and pass
Values through excel sheet to automate any application.
4. I tried my best to develop a framework which will never break even in the case of any exception. If any
exception will come while execution then it will handle that exception and proceed to the next test
case.
5. I am very confident on my html result reports and I’m quite sure that any technology at present time is
not providing such a detailed and well managed result report
6. While automating an application through this framework at the same time we will get proper
documentation regarding all test cases, which will be helpful to fix any unexpected situation in future.
This framework provides all flexibility/facilities like: -
1. Add end number of Applications.
2. Browser and device compatible.
3. Flexibility to ON/OFF Modules.
4. Flexibility to ON/OFF Test Cases.
5. Fully independent Test Cases.
6. Auto captured and save Screenshot of failed TCs.
7. All features are 100% dynamic, nothing is hard coded.
8. Flexibility to add new Methods (Functions). This framework will never say "No".
9. Well managed and detailed HTML Results including Project Name, Project URL, Test Device, Test
Operating System, Test Browser, Test Date, TC Name, TC Description, Action performed, Inserted
Values, Expected Result, Actual Result, Status, Total TCs, Total TCs Pass, Total TCs Fail, Total Validations
Pass, Total Validations Fail and Total time taken for execution.
Technologies used:-
Eclipse (Integrated Development Environment)
JSA Test Automation Framework Page 2
Java Programming language
Selenium Web Driver Java Library (jars)
Appium
Appium java client, gson and selenium server standalone jars
Microsoft Excel
Apache Excel (jars)
HTML
Browser Driver files
Description with screenshots: -
Below screenshot is showing the Project Excel file. From here, Software Tester OR Management can pass
the credentials and information regarding project and at execution time they can choose which project
needs to be executed on which device, on which OS, on which browser, etc.
JSA Test Automation Framework Page 3
Below screenshot is again showing the Project Excel file but different sheet (Project Modules Excel file).
From here, Software Tester OR Management can Create Modules Name and at execution time they can
choose which module(s) need to be executed.
Below screenshot is showing the Test Cases Excel file. From here, Software Tester can Create Test Cases
and at execution time Software Tester OR Management can choose which Test Cases need to be executed.
JSA Test Automation Framework Page 4
Below, first screenshot is showing the Test Data Excel file. From here, Software Tester can automate test
cases by using inbuilt Functions (Methods, Keywords) and pass all required information.
And, second screenshot is showing the HTML Result file with all required information in it after execution
JSA Test Automation Framework Page 5
Below, first screenshot is showing an another example of Test Data Excel file with 2 test cases. Here, in
first test case I am double verifying the user name after login.
And, second screenshot is showing HTML Result file after the execution of these 2 test cases.
JSA Test Automation Framework Page 6
Name and Description of Inbuilt Functions / Methods / Keywords
Fn_LaunchBrowser This function will open the browser on the bases of selected browser under “BrowserType” column in the
“ProjectDriver” excel file.
Fn_MaximizeWindow This function will maximize the browser window.
Fn_SetImplicitWait
If this function is called after LaunchBrowser then the script will always wait for the element as per the
provided time. Maximum wait will be as per the provided value and if script got the element sooner then it
will proceed to the next step. Value needs to pass in seconds.
To execute this function, data needs to be pass from “TestData” excel file: Value
Fn_SetPageLoadTimeout
This function will set the maximum wait to load the page. If a page will not load within the provided time
then the test step will be failed and the scrip will proceed to next step. Maximum wait will be as per the
provided value. Value needs to pass in seconds.
To execute this function, data needs to be pass from “TestData” excel file: Value
Fn_LaunchApp
This function will launch the application on the bases of URL passed under “ProjectUrl” column in the
“ProjectDriver” excel file.
Fn_GetAndVerifyTitleEquals
This function will get the actual title of the page and compare it with the expected title. If it matches then
the result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: Expected
Fn_GetAndVerifyTitleContains
This function will get the actual title of the page and compare it with the expected title. If actual title
contains the expected title then the result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: Expected
Fn_GetAndVerifyURLEquals
This function will get the actual url of the page and compare it with the expected url. If it matches then the
result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: Expected
Fn_GetAndVerifyURLContains
This function will get the actual url of the page and compare it with the expected url. If actual url contains
the expected url then the result will be pass else fail.
JSA Test Automation Framework Page 7
To execute this function, data needs to be pass from “TestData” excel file: Expected
Fn_ElementExist
This function will check whether the expected element is present within the page or not. If it is present
then the result will be pass otherwise fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_ElementNotExist
This function will check whether the expected element is present within the page or not. If it is present
then the result will be fail otherwise pass.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_Click
This function will click on the element.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_MouseMove
This function will hover the mouse cursor on the element.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_RightClick
This function will right click on the element.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_SetValue
This function will enter the value (text) in the textbox.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI, Value
Fn_GetAndVerifyValueEquals
This function will get the actual value from the textbox and compare it with the expected value. If it
matches then the result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, Expected
Fn_GetAndVerifyValueContains
This function will get the actual value from the textbox and compare it with the expected value. If the
actual value contains the expected value then the result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, Expected
Fn_ClearValue
This function will clear (remove) the value (text) from the textbox.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_SelectOption
This function will select the value (option) from the dropdown list.
JSA Test Automation Framework Page 8
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI, Value
Fn_GetAndVerifySelectedOptionEquals
This function will get the selected value (option) from the dropdown and compare it with the expected
value. If it matches then the result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI,
Expected
Fn_GetAndVerifySelectedOptionContains
This function will get the selected value (option) from the dropdown and compare it with the expected
value. If the actual value contains expected value then the result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI,
Expected
Fn_GetAndVerifyMultipleSelectedOptionsEqualsOneByOne
This function will get all the selected values (options) from the dropdown and compare it with the
expected value. If it matches then the result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI,
Expected
Fn_DeselectOption
This function will deselect a value (option) from the dropdown.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI, Value
Fn_DeselectAllOptions
This function will deselect all values (options) from the dropdown.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_VerifyElementEnabled
This function will check whether an element is enabled or not. If it is enabled then the result will be pass
otherwise fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_VerifyElementDisabled
This function will check whether an element is disabled or not. If it is not enabled then the result will be
pass otherwise fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_CheckOption
This function will check an option (Radio button or Check box). If the option by default checked then script
will not do anything and write the result pass otherwise script will click on option and write the result pass.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
JSA Test Automation Framework Page 9
Fn_UncheckOption
This function will uncheck an option (Radio button or Check box). If the option by default unchecked then
script will not do anything and write the result pass otherwise script will click on option and write the
result pass.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_VerifyOptionChecked
This function will check whether an element (Radio button or Check box) is selected or not. If it is selected
then the result will be pass otherwise fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_VerifyOptionNotChecked
This function will check whether an element (Radio button or Check box) is selected or not. If it is selected
then the result will be fail otherwise pass.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI
Fn_SwitchToSecondWindow
This function will switch (navigate) the script focus to second opened window (page).
Fn_VerifyAndCloseSecondWindowWithTitle
1. This function will switch (navigate) the script focus to second opened window (page).
2. Then it gets the actual title of new opened window.
3. Then it compares the actual title of new opened window with expected title. If it matches then the
result will be pass otherwise fail.
4. Then it close the new opened window (page) and switch (navigate) the script focus back to first
window.
To execute this function, data needs to be pass from “TestData” excel file: Expected
Fn_VerifyAndCloseSecondWindowWithURL
5. This function will switch (navigate) the script focus to second opened window (page).
6. Then it gets the current URL of new opened window.
7. Then it compares the current URL of new opened window with expected URL. If it matches then the
result will be pass otherwise fail.
8. Then it close the new opened window (page) and switch (navigate) the script focus back to first
window.
To execute this function, data needs to be pass from “TestData” excel file: Expected
Fn_VerifyAndAcceptAlert
1. This function will switch the script focus to alert and then get the text available on the alert.
2. Then it compares the actual text available on the alert with expected text. If it matches then the result
will be pass otherwise fail.
3. Then it accepts the alert.
JSA Test Automation Framework Page 10
To execute this function, data needs to be pass from “TestData” excel file: Expected
Fn_VerifyAndDismissAlert
1. This function will switch the script focus to alert and then get the text available on the alert.
2. Then it compares the actual text available on the alert with expected text. If it matches then the result
will be pass otherwise fail.
3. Then it dismisses the alert.
To execute this function, data needs to be pass from “TestData” excel file: Expected
Fn_GetAndVerifyTextEquals
This function will get the text through provided element path and compare it with the expected text. If it
matches then the result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, Expected
Fn_GetAndVerifyTextContains
This function will get the text through provided element path and compare it with the expected text. If the
actual text contains expected text then the result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, Expected
Fn_NavigateToURL
This function will open a new url within the same window, then get the actual url and compare it with
provided url. If it matches then the result will be pass else fail.
To execute this function, data needs to be pass from “TestData” excel file: Value
Fn_ScrollToElement
This function will scroll the web page to the location where the element is available.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath
Fn_VerifyValueInWebTableEquals
1. This function will get all the elements on the bases of provided locator (xpath, id, etc.)
2. Then it extracts the actual text from all elements one by one and compares it with expected text. If it
matches then the result will be pass otherwise fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, Expected,
ElementUI
Fn_VerifyValueInWebTableContains
3. This function will get all the elements on the bases of provided locator (xpath, id, etc.)
4. Then it extracts the actual text from all elements one by one and compares it with expected text. If the
actual text contains the expected text then the result will be pass otherwise fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, Expected,
ElementUI
JSA Test Automation Framework Page 11
Fn_FindAndClickValueInWebTableEquals
1. This function will get all the elements on the bases of provided locator (xpath, id, etc.)
2. Then it extracts the actual text from all elements one by one and compares it with expected text.
3. If it matches with expected text then it will click on that text (element) and write the result pass and if
it does not match with anyone then the result will be fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, Expected,
ElementUI
Fn_FindAndClickValueInWebTableContains
4. This function will get all the elements on the bases of provided locator (xpath, id, etc.)
5. Then it extracts the actual text from all elements one by one and compares it with expected text.
6. If the actual text contains the expected text then it will click on that text (element) and write the result
pass and if nothing contains this text then the result will be fail.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, Expected,
ElementUI
Fn_UploadFile
This function will upload a file through file input type.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath, ElementUI, Value
(file path)
Fn_BackSpace
This function will perform backspace (navigate to previous page).
To execute this function, data needs to be pass from “TestData” excel file: ElementPath
Fn_ForwardSpace
This function will perform forward space (navigate to forward page).
To execute this function, data needs to be pass from “TestData” excel file: ElementPath
Fn_DragAndDrop
This function will split the provided elements path and elements UI into array and drag the first element
path and drop it to second element path.
To execute this function, data needs to be pass from “TestData” excel file: Two ElementPaths separated
with comma (,) and Two ElementUIs separated with comma (,)
Fn_ClickIfAnotherElementNotExist
This function will split the provided elements path and elements UI into array and click on first element if
second element does not exist.
To execute this function, data needs to be pass from “TestData” excel file: Two ElementPaths separated
with comma (,) and Two ElementUIs separated with comma (,)
JSA Test Automation Framework Page 12
Fn_Wait
This function will wait for the next execution as per the provided time. Value need to pass in milliseconds.
To execute this function, data needs to be pass from “TestData” excel file: Value
Fn_WaitForTitleContains
This function will wait till the time title will not contains expected value. Maximum wait will be as per the
provided value. Value need to pass in seconds.
To execute this function, data needs to be pass from “TestData” excel file: Value, Expected
Fn_WaitForURLContains
This function will wait till the time URL will not contains expected value. Maximum wait will be as per the
provided value. Value need to pass in seconds.
To execute this function, data needs to be pass from “TestData” excel file: Value, Expected
Fn_WaitForAlertPresent
This function will wait till the time alert will not present. Maximum wait will be as per the provided value.
Value need to pass in seconds.
To execute this function, data needs to be pass from “TestData” excel file: Value
Fn_WaitForElementVisible
This function will wait till the time element will not be visible. Maximum wait will be as per the provided
value. Value need to pass in seconds.
To execute this function, data needs to be pass from “TestData” excel file: Value, ElementPath
Fn_WaitForElementClickable
This function will wait till the time element will not be clickable. Maximum wait will be as per the provided
value. Value need to pass in seconds.
To execute this function, data needs to be pass from “TestData” excel file: Value, ElementPath
Fn_WaitForNumberOfWindows
This function will wait till the time the number of windows will not be equal to expected. Maximum wait
will be as per the provided value.
To execute this function, data needs to be pass from “TestData” excel file: Value, Expected
Fn_RefreshPage
This function will refresh the page.
Fn_DeleteCookies
This function will delete the cookies of opened browser.
JSA Test Automation Framework Page 13
Fn_CloseTab
This function will close a tab or browser but does not break the connection with browser.
Fn_QuitBrowser
This function will quit all the tabs or browser and also break the connection with browser.
Fn_ClickWithJavaScript
This function will click on the element.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath (Need to pass Id
only), ElementUI
Fn_SetValueWithJavaScript
This function will enter the value (text) in the textbox.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath (Need to pass Id
only), ElementUI, Value
Fn_CheckCheckboxWithJavaScript
This function will check the checkbox.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath (Need to pass Id
only), ElementUI
Fn_UncheckCheckboxWithJavaScript
This function will uncheck the checkbox.
To execute this function, data needs to be pass from “TestData” excel file: ElementPath (Need to pass Id
only), ElementUI
JSA Test Automation Framework Page 14
An examples, how code works behind the Functions / Methods / Keywords
Fn_LaunchBrowser
case "Fn_LaunchBrowser": Fn_LaunchBrowser(); break;
public void Fn_LaunchBrowser() throws Throwable
{
try
{
if(DriverScript.vBrowserType.equals("Mozilla Firefox"))
{
DriverScript.driver=new FirefoxDriver();
}
else if(DriverScript.vBrowserType.equals("Google Chrome"))
{
System.setProperty("webdriver.chrome.driver","D:\\Selenium\\JSA_TestA
utomationFramework\\Drivers\\Web Browsers\\ChromeDrivers
2.20\\chromedriver_win32\\chromedriver.exe");
DriverScript.driver=new ChromeDriver();
}
else if(DriverScript.vBrowserType.equals("Internet Explorer"))
{
System.setProperty("webdriver.ie.driver","D:\\Selenium\\JSA_TestAutom
ationFramework\\Drivers\\Web Browsers\\IEDrivers
2.51.0\\IEDriverServer_Win32_2.51.0\\IEDriverServer.exe");
DriverScript.driver=new InternetExplorerDriver();
}
else if(DriverScript.vBrowserType.equals("Microsoft Edge"))
{
System.setProperty("webdriver.edge.driver","C:\\Program Files
(x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe");
DriverScript.driver=new EdgeDriver();
}
else if(DriverScript.vBrowserType.equals("Safari"))
{
DriverScript.driver=new SafariDriver();
}
else if(DriverScript.vBrowserType.equals("Opera"))
{
System.setProperty("webdriver.opera.driver","D:\\Selenium\\JSA_TestAu
tomationFramework\\Drivers\\Web Browsers\\OperaDrivers
0.2.2\\operadriver_win64\\operadriver.exe");
DriverScript.driver=new OperaDriver();
}
else if(DriverScript.vBrowserType.equals("iOSSafari"))
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName",
DriverScript.vDeviceName);
capabilities.setCapability("platformName",
DriverScript.vPlatformName);
capabilities.setCapability("platformVersion",
DriverScript.vPlatformVersion);
capabilities.setCapability(CapabilityType.BROWSER_NAME,
"safari");
JSA Test Automation Framework Page 15
DriverScript.driver=new IOSDriver(new
URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
else if(DriverScript.vBrowserType.equals("AndroidChrome"))
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName",
DriverScript.vDeviceName);
capabilities.setCapability("platformName",
DriverScript.vPlatformName);
capabilities.setCapability("platformVersion",
DriverScript.vPlatformVersion);
capabilities.setCapability(CapabilityType.BROWSER_NAME,
"Chrome");
DriverScript.driver=new AndroidDriver(new
URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
DriverScript.hr.fgInsertResult(DriverScript.ResFilePath, "Launch
Browser ("+DriverScript.vBrowserType+")", "Browser should launch", "Browser
launch successfully", "PASS);
}
catch(Throwable t)
{
DriverScript.hr.fgInsertResult(DriverScript.ResFilePath, "Launch
Browser", "Browser should launch", "Unable to launch browser", "FAIL");
}
}
Recently, I have integrated and customized an amazing Result Report in this framework,
below are the screenshots of the same:
JSA Test Automation Framework Page 16