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.
by admin | Jan 14, 2020 | Automation Testing, Fixed, Blog |
Lemoncheesecake is a very well known Python testing framework. As a test automation services company, we have evaluated this framework for one of your automation testing projects. After the proof of concept stage, we decided to use lemoncheesecake framework to write automation test scripts. Initially, BDD support was not available. However, now you can use behave BDD framework in lemoncheesecake. In this blog article, you will learn how to write BDD tests using lemoncheesecake and behave frameworks.
Step #1: Installation
To setup BDD using behave and lemoncheesecake, you need only two dependencies (behave and lemoncheesecake packages). That’s it.
pip install lemoncheesecake
pip install behave
Step #2: Setup LemonCheeseCake Project
Once the required dependencies are installed, you need to create LemonCheeseCake project. There is a command to do that. Run the below command. It will create LemonCheeseCake (LCC) project for you.
Step #3: Create a Feature
Create ‘features’ folder inside ‘myproject’ folder. Create a feature file inside the features folder.
Feature: LemonCheeseCake Demo
Scenario: Demo Scenario
Given I fill login details
When I click login button
Then I should see Home page
Step #4: Step Definition
from behave import *
import lemoncheesecake.api as lcc
from lemoncheesecake.matching import *
@given("I fill login details")
def step_impl(context):
lcc.log_info("Pass")
@when("I click login button")
def step_impl(context):
lcc.log_info("Pass")
@then("I should see Home page")
def step_impl(context):
lcc.log_info("Pass")
Step #4: Create environment.py
Create environment.py inside myproject folder to install BDD hooks from behave.
from lemoncheesecake.bdd.behave import install_hooks
install_hooks()
Step #5: Run
behave features/demofeature.feature
Once the execution is complete, you can find LCC HTML report in reports folder. The best thing about LCC is reporting. Your team will love it once they start getting reports from LemonCheeseCake framework.
In Conclusion
Why does one need to integrate behave with LCC? We as a software testing company, write BDD and non-BDD automated scripts using Java, Python, and JavaScript languages. Let’s say for instance if u wish to write automated test scripts for data quality checks and UI validations in a test automation framework. Then LemonCheeseCake and behave combination is the ideal choice. LCC framework is gaining popularity among automation testers. We hope that you have gained some useful insights from this article. Every other day, we publish a technical blog article. Subscribe to Codoid’s Blogs to get our updates on the recent technical developments, feel free to contact us for your automation testing needs.
by admin | Jan 17, 2020 | Automation Testing, Fixed, Blog |
Most companies are affected by some problem or the other in new test automation services projects. Keep such windfalls in mind and build stable automation frameworks and ensure a collaborative team effort and own your automation. For automation to be successful, companies should approach it with realistic goals, the right attitude, and a willingness to make it work. Here are eight reasons your automation project can fail:
Unable to describe individual business goals that need to be solved:Return On Investment (ROI) should be understood if you are running automation tied to a business goal, then business leaders will stay invested. Use an open-source tool and hook it into your build server and spend time making your project feature-rich by writing test cases that are aligned to the same business goal.
Automation should be treated as a timed activity and not a process:Make sure developers who build the automation framework hand it over to a competent technical QA team to carry forward. Automation is a software project and should be flexible and easy to maintain. Continuous work needs to be done to update the framework, like new updates, features, and requirements. Most frameworks are tied into other systems like build, metrics, and cloud services, so keep it synced as it evolves.
A team creates it without sole responsibility for standards:Slower test case development by a smaller team that builds in redundancy and regularly reviews and gives feedback to produce quicker value to the project. This team checks requirements, understand business goals, and builds infrastructure to drive the project forward. With strong leadership, an approved roadmap, and strict quality controls, the team should be confident in their tests and its ability to produce reliable results. Each test should be reviewed to ensure it fits, and the team’s QA engineers should be autonomous.
Understand what to and what not to automate:It is imperative to understand that it is good to automate certain functionalities of a webpage and that some scenarios are better tested manually. Only automate stable aspects of your app or web product that is not prone to change but needs to be continuously retested. Save valuable testing effort by automating such repetitive tasks and ensure testers spend time performing exploratory testing.
The team isn’t technically skilled enough to handle the project:Testers should have a certain level of technical expertise to do automation the right way. Such QA team members can be expensive, and not all companies can afford to hire such automation engineers. So hire a few technical experts, but if it isn’t an option, invest in a tool that can help you automate the processes.
Lack of visibility around automation techniques:To be more visible, create an automation document listing all features automated, modules covered, and framework set up. Your method of automation should be clearly defined for the entire Software Development Lifecycle (SDLC). Automation tasks need to be treated separately to make them easier to manage. Make the results visible to the whole team via dashboards and discuss daily progress in team huddles. Conduct sessions that cover different trends, ethical practices, and tools. Make your automation a collaborative effort by involving the complete team in planning and writing it.
Check the testability of the application:Build an application that is easily testable from all (unit, system, integration, and acceptance) levels. Don’t build complex applications that cannot be tested and ensure the testability of a story, feature, or requirement during backlog sprucing, and sprint planning meetings before the development begins. It will alleviate problems later in the SDLC.
Vague automation goals:A robust automation framework seamlessly integrates with Continuous Integration/Continuous Delivery (CI/CD) pipeline, is easily maintainable because it gives quick feedback and runs consistently. Identify two or three high-level functionalities and collect input from automating and stabilizing them first. Separate your automation suites for smoke tests (run after every code check-in) and regression tests (run daily and covers different functionalities).
In summary, these common reasons that cause automation to fail need to be avoided for a successful automation implementation. Keep your projects focused on increasing ROI and business value and hire a highly skilled team or test automation company to ensure a smooth transition. Automation testing companies, like Codoid, can help you in this respect.
by admin | Dec 10, 2019 | Automation Testing, Fixed, Blog |
Automation Testing success can be measured using its metrics. Analyzing only the last execution results will not help you to determine test automation success completely. In order to achieve better results, you need to save all the historical execution results to enable automation testing metrics. For example: if you want to know how many times a feature is passed and failed, then you will have to ingest each execution’s test result in a database and create a web dash board. So that your team can see what benefits we have reaped so far from automated testing.
As a leading automation testing company, while formulating test automation metrics we consider the following two crucial aspects.
- Automation Testing Benefits perspective.
- Script Quality Perspective. if an automated script keeps on providing false-positives, then it will be an indication for automation testing team to make the script robust enough to stop false positives. Let’s see all the required automation testing metrics one by one.
Pass and Fail count from last execution helps to conclude the testing. However, if you get more failures, then automation testers should troubleshoot the failures. If a failure is a false positive, then check how many times the script failed in the past and mark it for the update. When sharing the historical failures count, your team only focuses is to stop false positives.
Automation testing starts from the senior management. They are the one who approve the budget to kick-off automation testing project to reap benefits from it. As soon as the project is started, sharing how many scripts are converted from manual to automation on weekly basis is a vital information for the management team. Consider, 30% of test cases are not automated due to various reasons. your team can plan how much effort is required for manual regression testing for the non automated test cases.
If you have automated test suite, then it should be utilized as much as possible for various testing activities. No. of executions is a great metric for your team and management. Once the regression testing is taken care by automation, the testers from your team will get more time to conduct exploratory testing and to test new features, stories, & other impacted areas manually. No. of times the automated test suite executed metric is an input to your management team to measure the success of test automation.
This metric is useful to enhance scripts quality. How? If you are capturing failure count for Feature, Scenario, and Step level, then you can easily identify automated scripts which are failing often. When your test automation suite is robust enough, then it will add more value to your testing.
Execution duration metric is an input for your team and management. Let’s see how is it valuable to the management team? If everyone in your team is aware of how quickly your automated smoke and regression test suites complete the execution, then your team can take important decision on how many hours/minutes do we need to show up maintenance page during product release deployment? And how many hours do we need to wait to complete the regression testing on lower environments? Even your team can revisit the scripts to fine tune to reduce the execution time.
We recommend you not to execute your automation testing scripts without collecting metrics. Doing so will be a great value add to your project. You can capture many metrics. However, as a first step, capturing the test automation metrics which are mandatory and useful is important. As a test automation services company, we collect metrics to make the effort visible to clients, and the management so as to improve the scripts’ quality.