by admin | Feb 20, 2020 | Automation Testing, Fixed, Blog |
It is an Open-source UI based automation library to test your application which runs on Windows OS. It wraps almost all of the libraries used in the Microsoft UI Automation Test Library. We can use FlaUI libraries to automate win32, WinForms, WPF and Windows Store apps.
The below are the libraries provided by FlaUI, we will see the uses of those libraries against each one of them:
FlaUI.core – This Library will has base elements used in the concrete implementations of FlaUI.
FlaUI.UIA2 – This Library is used to automate win32 and winforms applications.
FlaUI.UIA3 – This Library is used to automate WPF and windows store apps.
Prerequisites: – You should have Visual Studio IDE installed in your machine.
Installation of FlaUI:
1. Create a New Project in Visual Studio
2. Right-click on the project and select “Manage NuGet Packages” (Using NuGet Package Manager)
3. Select the ‘Browse’ tab and Search for FlaUI, it will display the FlaUI libraries.
4. Install the below libraries from NuGet package manager
FLAui.core, Flaui.uia2, Flaui.uia3.
NOTE: The downloaded libraries are limited to the project, which means it is not available by default for all projects.
How to launch the application using FlaUI:
1) To start testing one should implement the static method “Launch” from the “Application” class which is available in FlaUI.Core library.
2) You should pass the application path (the application you installed in your machine and you want to automate) as a parameter to the Launch method as given in the below example.
Example:
var msApplication = Application.Launch(@"C:Program FilesMicrosoft OfficeOffice16WINWORD.EXE");
var automation = new UIA3Automation();
var mainWindow = msApplication.GetMainWindow(automation);
The above code tells you
1. How the launch method is implemented using the Application class, and how the application path is passed as a parameter (First Line).
2. In the second line, we are specifying the Automation Library Type (UIA3) used to automate the app.
3. The third line describes getting the main window instance from the application instance.
Searching an Element in the Application:
1) To find the element in the application, we need to specify the treeScope of the AutomationElement.
2) We can specify the AutomationElement by providing conditions like ConditionFactory, ControlType, and action to be performed as explained in the below example.
ConditionFactory cf = new ConditionFactory(new UIA3PropertyLibrary());
mainWindow.FindFirstDescendant(cf.ByName("Text Editor")).AsTextBox().Enter("FlaUI Tutorial");
Code Explanation:
1. The first line is creating the “ConditionFactory” instance, the “ConditionFactory” is the class from “FlaUI.Core”, “ConditionFactory” identifies the element based on the condition.
2. We are specifying the TreeScope {FindFirstDescendant()}, ConditionFactory{ByName()}, ControlType {AsTextBox()} and action {Enter()} of the automation element.
The above helps us to install FlaUI and run an application. We must know how to inspect an element using FLAUInspect. We need the Chocolatey package manager to install Flauinspect, we will see the step by step process of the implementation below.
1. Chocolatey is the package manager for windows. The Flauinspect is a package under the Chocolatey package manager. So it is mandatory to install Chocolatey to inspect the AutomationElement.
2. Go to https://chocolatey.org/install and follow the instructions to install Chocolatey.
3. After installing chocolatey, run this command “choco install flauinspect” in command prompt to install Flauinspect.
4. To launch Faluinspect, run this command “flauinspect”, it will open the Flauinspect application.
Working with Flauinspect:
There are three ways for inspecting an element
Open Flauinspect > go to “Mode” >
1. Hover Mode (Press ctrl and move your mouse pointer focus on the target element)
2. Focus Tracking ()
3. Show XPATH, (combine with any mode listed above) and it will show only the absolute XPath.
Capture Screenshot with FlaUI:
Flaui provide a “Capture” class for the screenshot
Capture.screen();
// It will capture the full screen
Capture.Element("That Element ");
//It will capture the specific element
Capture.Rectangle("Specify the height, width and length")
//It will capture the specific block you specified in the parameter.
We can store the screenshot in a file by using the below lines of code:
var image = Capture.Screen();
image.ApplyOverlays(new MouseOverlay(image.DesktopBounds));
image.ToFile(@"c:tempscreen.png");
NOTE: ToFile(“Your_Location”) method can be used to store the screenshot in a user-specified location.
Perform Mouse Action using FlaUI
The Flaui provides the Mouse Class with different methods as follows:
1. Mouse left click
Mouse.LeftClick();
// left click where the mouse pointer is currently pointed to.
2. Point
Point point = new Point(2435, 234 )
// This will provide the location of the mouse pointer (X-axis and Y-axis).
3. Middle Click
Mouse.Click(MouseButton.Middle, point);
4. MoveTo and MoveBy and Position
Mouse.MoveTo(point)
// Will position the mouse pointer to the New location
Mouse.MoveBy(point)
// it will take the current location and add the point specified in the method then drag the mouse to the location specified.
Mouse.Position(point)
// the traces of the mouse pointer are not displayed.
5. Scroll
Mouse.Scroll(10)
// positive value to scroll up ; Negative Value to scroll down
Mouse.HorizontalScroll(40);
Mouse.VerticalScroll(30);
Perform Keyboard Action using FlaUI
To perform any action the application via Keyboard, the FlaUI provides the Keyboard class with the following methods:
Keyboard.Type("Hello Flaui"); // for a string
Keyboard.Type(VirtualKeyShort.Key_B, VirtualKeyShort.Key_C);
Keyboard.Press(VirtualKeyShort.BACK) // backspace
//For Combinations of multiple keystrokes (To press a key and release a key)
Keyboard.Pressing(VirtualKeyShort.CONTROL);
Keyboard.Press(VirtualKeyShort.Key_A);
Keyboard.Release(VirtualKeyShort.CONTROL);
//Another Way for the combinations key
Keyboard.TypeSimultaneously(VirtualKeyShort.CONTROL,VirtualKeyShort.KEY_A);
NOTE: VirtualKeyShort is available in “FlaUI.Core.WindowsAPI” package
How to highlight the element in FlaUI:
Flaui provides the “DrawHighlight” method which will highlight the AutomationElement.
Automation_Element.DrawHighlight();
Thank you for reading the above article, we would love to hear your comments. Please write to us if you face any issue in using FlaUI, we are happy to help. Happy Testing!
Frequently Asked Questions
-
What is FlaUI?
FlaUI is an open-source .NET library based on the native UI automation libraries of Microsoft that can be used to automate UI-based testing of Windows applications such as win32, WinForms, WPF, and Windows Store apps.
-
Is FlaUI open source?
Yes, FlaUI is indeed an open-source UI-based automation library that can be used to perform Automated UI testing of Windows applications such as win32, WinForms, WPF, and Windows Store apps.
-
How do I install the FlaUI library?
1. Create a new project in Visual Studio.
2. Right-click on the project and select “Manage NuGet Packages”.
3. Select the ‘Browse’ tab and Search for FlaUI.
4. Install the FLAui.core, Flaui.uia2, Flaui.uia3 libraries.
by admin | Jan 3, 2020 | Automation Testing, Fixed, Blog |
We at Codoid use various automation testing tools. In this blog article, we would like to share the tools that we use and why. As a Test Automation Services Company, using multiple test automation tools/libraries has become inevitable for us to address automation testing challenges. If you don’t know how to use a tool, then your output will be a mess. In-depth knowledge of various automation testing tools is must to deliver high quality automated test scripts. Let’s see the tools we use for automation testing.
For web application automation testing, we use Selenium WebDriver & Protractor. Python, Java, C#, and JavaScript are the programming languages which are predominantly used to write test automation scripts. To enable effective collaboration with the clients’ SPOC, Gherkin steps are written using Cucumber and Behave BDD frameworks. Our Automation CoE Team suggests Selenium best practices periodically to produce quality automated test scripts.
To automate desktop app test cases, we use White Framework and Test Complete. White Framework is an open source library to automate desktop applications. Automating a desktop application using White Framework is no cake walk. It requires in-depth knowledge on White Framework, Win32 API, and C#. As an automation testing company, we have helped our clients to automate their Desktop test cases using both White Framework and Test Complete.
For mobile app automation, the best choice is Appium. Once the automated test scripts are ready for mobile app test cases, we run them on cloud real-devices using BrowserStack and Kobiton platforms.
Firing all the validations SQL queries manually on daily basis is a boring task for a tester. We have setup an automation testing framework using Python and LemonCheeseCake library to compare source and target data. If your team needs any help in automating data quality validations, contact us to explore our test automation solution.
The most apt automation testing tools will invariably lead to successful test automation. As a leading software testing services company, automation testing is one of our core services. continuous learning and following up automation best practices help us to deliver robust test automation suites to our clients efficiently
by admin | Dec 30, 2019 | Automation Testing, Fixed, Blog |
Microservices are important to the companies who want to build and deploy systems that are scalable, flexible, adaptable, and easy to develop. Automation tests are therefore needed to take things to live regularly. Microservices are modular and independently deployable as small composable components and thus are separately testable. As testing scales up from small independent microservices through integration and end-to-end testing to larger services ecosystems, it influences the testing pyramid.
So what is a Microservice?
Microservices is a part of software architecture. It involves developing single applications that can work together as a suite of small services, each running its process while communicating with HTTP resource API mechanisms. They require minimal centralized management systems and various data storage technologies and are written in multiple programming languages.
Service-Oriented Architecture (SOA) vs. Microservices
An SOA model is a dependent Enterprise Service Bus (ESB), whereas ‘Microservices’ use faster mechanisms. SOA focuses on imperative programming, and microservices use a responses-actor based programming style. SOA models also have outsized relational database management systems, yet microservices databases like NoSQL or micro-SQL connect to conventional databases. We can conclude that the architecture methods thus differ in how each creates an integrated set of services.
Service layer and test automation API Tests
Deploy multiple versions of service API’s in parallel and make sure that the version number appears at the endpoint address. When we create a microservice, service layer testing is complemented with API tests.
Let’s discuss five approaches to automation tests for microservices.
Unit testing
It is internal to the service and is the largest in terms of volumes. It should be automated based on development language and framework. Written at unit level or collection of units as the goal is to check parts of the software to validate for functionality.
Contract testing
It treats each service individually and independently call them to verify their responses. It also reframes testing principles and maps it to service layers of a testing pyramid. Considered a cost-effective substitute for integration tests.
Integration testing
Perform verification of the services that have been individually tested and check the functioning of inter-service communications. It validates if the system works seamlessly and that the dependencies between the services are present as expected. Limit the volume of full integration tests and write layer integration tests to ensure proper integration.
End-to-End (E2E) systems testing
E2E testing verifies if the entire process flow works correctly and includes all service and database integrations. Frameworks help automate functional testing by checking that the system behaves as expected when you deploy your application in a real-world environment.
Interface testing
User Interface (UI) testing is the final level of automation testing and checks the system in a
real-time end-user scenario before the application goes live.
The benefits of microservices in a large scale systems development is still contested. That’s why we recommend you install microservices only if a regular SOA does not meet your needs. If you are considering microservices, look no further than Codoid . As a test automation services company, we ensure that all testing is performed by the right set of qualified personnel to give the best quality output to our customers. Our testing tools accelerate testing for better productivity and shorter time to market. As automation tests are an essential requirement to create successful microservice architectures, we work together with our clients to help them deploy their products by giving them the best return on their investment with us.
by admin | Jan 9, 2020 | Automation Testing, Fixed, Blog |
We all know that Selenium has three wait types (Implicit, Explicit, and FluentWait). How to avoid false positives using Selenium waits? Applying wait for all FindElement steps using Implicit Wait is not a right approach. If you are automating a small website or writing some Web scraping scripts, you can go with Implicit Wait. However, if you are writing automated test scripts for an web application, then our recommendation is Explicit Wait. Moreover, Implicit Wait applies the wait time for the entire browser session and you can change the wait time during run-time, however, you can’t do it for individual FindElement method call. As an automation testing company, we use Selenium Explicit Wait to avoid false positives as much as possible. In this blog article, you are going to learn Selenium Wait Commands using Python.
Implicit Wait
As we mentioned before, use Implicit Wait for simple website or Web scraping scripts and don’t mix Implicit and Explicit Waits. When you automate a full regression test suite, it requires proper Page Load and AJAX call handling using Explicit Wait. Note: By default, Implicit Wait is disabled.
from selenium import webdriver
driver = webdriver.Chrome(executable_path='chromedriver.exe')
driver.get("https://codoid.com")
driver.implicitly_wait(10)
Visibility of Element Located
Checking the presence of an element in DOM will not suffice our need. In addition to that the scripts need to confirm whether the web element is displayed on the web page or not. Selenium Explicit Wait has visibility_of_element_located method to check whether the web element is available in DOM and Height & Width is greater than ‘0’. Most of the automation testers are aware of this method/technique. However for novice QA automation testers to write robust automation test scripts this will be a much useful tip. Your developers can hide web elements for different reasons using the below CSS attributes.
<input type="text" id="txt1" style="opacity: 0"/>
<input type="text" id="txt1" style="visibility: hidden"/>
<input type="text" id="txt1" style="display: none"/>
<input type="text" id="txt1" style="position: absolute;top: -9999px;left: -9999px;"/>
<input type="text" id="txt1" style="clip-path: polygon(0px 0px,0px 0px,0px 0px,0px 0px);"/>
Note: If any HTML tag is styled using clip-path, Selenium’s visibility check does not work. This may be an issue with Selenium. Let’s wait for the comments.
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as cond
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
driver = webdriver.Chrome(executable_path='chromedriver.exe')
wait = WebDriverWait(driver, timeout=10)
try:
driver.get("http://google.com")
wait.until(cond.visibility_of_element_located((By.NAME,"txt")))
except TimeoutException as e:
print("Timed Out")
finally:
driver.quit()
Wait for JavaScript Alert Presence
JavaScript Alert will pops out on your web browser after its invocation. One should use wait mechanism while handling JS Alert to avoid script failure. Sometimes, due to Ajax call response delay, JavaScript Alert invocation will also be delayed. However, your automation script should wait for the expected delay to handle the alert.
wait.until(cond.alert_is_present)
Selenium Explicit Wait using Lambda Expression
You can also use Python Lambda Expression to simplify the Selenium Explicit Wait commands.
elemnt = wait.until(lambda d: d.find_element_by_id("txt"))
elemnt.send_keys("Codoid")
In Conclusion
As a leading test automation services company, we at Codoid follow best practices to develop robust automation testing scripts. We hope you have learnt the nuances of Selenium Explicit Wait techniques to avoid false positives from this blog article. Contact us for your automation testing needs.
by admin | Jan 10, 2020 | Automation Testing, Fixed, Blog |
Executing successful test automation is far more than just writing code. It requires a highly-skilled team that is disciplined to create long-term and innovative sustainable automation.
Here are some critical factors while building your team for automated testing:
1: The reality check is that sustainable test automation can’t be made quickly or easily. That’s why a competitive test automation team must be hired so that they can maintain the software and add new features or functionality in the future. Hire experts to assemble the right QA team to design your automation framework and test scripts. A dynamic team will be able to evolve with the changing needs of your app testing. Many businesses hire third-party companies to build test automation for them, and it is necessary to find a reputable one that adopts a sustainable plan for automation tools.
2: Choose an ideal candidate with a good track record as a team leader of your automation test team because this is a critical hire. The team should be skilled in building reusable code, leveraging functions, creating well-documented methods, and intuitive naming conventions. Avoid candidates who mention record-and-playback test automation development process or keyword-driven approaches since these are not effective automation techniques and return nil on investments. Look out for manual testers who can leverage automation as a tool for efficient and consistent test-case execution. Team members should be pro-learning and follow the approach and framework decided at the beginning.
3: Bring onboard specialists like a principal developer who has a robust methodology background who can positively contribute to the growth and scalability of your app/web. Such an infrastructure specialist will focus on framework development, test management, remote execution, etc. As your team grows, such areas of app/web development will become critical to your success, and additional niche specialists for reporting, analysis, project management, and administration will become a necessity.
4: Ensure that you have sufficient team members running QA for you so that you are adequately covered throughout the entire SDLC. The automation team equips tools and languages for the manual testing team. Sometimes it is better to hire or outsource to an automated testing services company where you get access to quality assurance leaders who can monitor the usage of automation by identifying problems.
The easiest way to switch to automated from manual testing would be to take help from an automation expert who will oversee the process.
If you already have a project where you need automated testing skills, then get the goals and strategy defined by this expert and identify critical issues.
You need appropriate instruments like tools and frameworks, and employing an experienced automated tester will help establish a path for you to switch from manual testing to automation.
To make the switch, you’ll have to set up the environment which requires software and hardware, and this will take time and resources and while increasing costs.
Slowly switch the process with few testers and ensure there is proper management to avoid errors by being well-documented. A skilled automation expert will simplify this process.
At Codoid, a test automation services company, we believe that the priorities in automated testing should be as follows project, team, and then tools. First, you should analyze your product, then select the right team to solve issues and choose tools that will assist your QA testers. Whether it’s an app or website decide what browsers, functions, and OS’s you want it to support. The more familiar you are with the latest technologies used in the development, the better your testing strategy will be. If you need your software to be perfected, contact our team of expert QA engineers.
by admin | Jan 12, 2020 | Automation Testing, Fixed, Blog |
Nowadays, we come across many articles related to Cypress vs. Selenium. If you don’t choose the automation testing tool based on you needs, then you will regret forever. Let’s hit the bulls eye – Cypress is not meant to be used by software testers. It is meant for Software developers to write automated Integration tests and Unit tests against a local development server.
If you are a tester and want to use Cypress for automated smoke testing, you can run your scripts on Chrome browser, but not on Firefox, Safari, and Internet Explorer browsers. Reading the main page of the tool and writing the tool review will not suffice the needs of your audience. Product based companies are referring the tool review blog articles before choosing an automation testing tool. A thorough and unbiased tool review will help them to get quick information about a tool.
Introduction
Cypress is a developer-focused tool. If you are a tester, don’t attempt to automate your regression test suite using Cypress.io. In other words, Cypress is a suitable automation testing tool for local development builds. Whatever testing activities you can perform on development environments, you can automate them using Cypress.
Installation
You can install Cypress using npm command or it can be downloaded directly as a Zip file. Note-If you have installed using npm, then you can update newer versions easily.
Scripting Language
Cypress’ scripting language is JavaScript and it is bundled with Mocha and Chai libraries. You can describe your tests and write assertion steps with them. You can also use Intellij IDE to write test scripts. Note: In order to enable ECMA Script 6 support in Intellij, go to Settings->Languages & Frameworks->JavaScript and Select “JavaScript Language Version” as “ECMAScript 6”.
describe('Codoid Review', function(){
it('Test 1',function(){
expect(true).to.equal(true)
})
})
Cypress Selectors
Cypress uses JQuery to find elements in DOM. Why JQuery? Simple. Cypress is for developers. Most of the modern day web developers are familiar with JQuery. It would be easy for them to write locators using JQuery syntax. By default, Cypress polls for 4 seconds to find an element. You can also change the timeout globally or on a per-step basis.
cy.get('.my-slow-selector', { timeout: 10000 })
Project Structure
Once a Cypress project is created, it will consist fours folders – ‘fixtures’, ‘integration’, ‘plugins’, and ‘support’.
- Test data can be stored in ‘fixtures’ folder.
- All your test files (.js, jsx, .coffe, and .cjsx) can be written inside the ‘integration’ folder.
Visual Testing
You can also write visual regression tests using Cypress Snapshots plugin. JQuery Selector finds element, Cypress performs action on the selected element, and the expected result will be asserted. However, if you want to validate whether the page or a web element is displayed as expected to the end user with all the images and applied CSS Styles, then you need to do visual testing.
Browser Support
Cypress supports Electron, Chromium and Chrome. Firefox, Safari, and Internet Explorer browsers are not supported. As Cypress tool is for Integration and Unit tests, running on one browser should be sufficient.
As a test automation company, we use multiple automation testing tools for various projects. We have a conviction that reviewing new tools and subsequently sharing the outcome by means of software testing blogs will immensely help automation test communities to select appropriate test automation tool based on their requirements and tool selection criteria. Contact us for your automation testing needs.