The retail industry is witnessing a transformative leap with AI integration, which is expected to generate significant profits. The blog discusses how AI enhances customer experience, optimizes inventory, and improves service through chatbots and personalized recommendations. With 87% of retailers adopting AI in some form, it is crucial for inventory management, dynamic pricing, and customer engagement despite facing integration challenges.
The post AI Integration in Retail: Top 5 Use Cases for 2024 first appeared on TestingXperts.
Artificial intelligence (AI) is rapidly evolving and is changing many different kinds of businesses and their processes. Software development is…
Using Selenium to try and locate + press a button inside of an Atlassian Jira environment.
The button class is not unique and the button doesn’t have a button ID. I assume the website is built in an incompatible way to interact with Selenium. All attempts end with no elements found. Has anyone got any suggestions?
I’m using PowerShell currently and have tired numerous search methods here’s the latest which I hoped would work but still nothing..
# Find the <span> element with the text “Update site”
$span_element = $driver.FindElementByXPath(“//span[text()=’Update site’]”)
# Navigate to its parent <button> element
$button_element = $span_element.FindElementByXPath(“./..”)
# Perform actions on the button
$button_element.Click()
There is a ton of information these days on every single phase involved in building AI algorithms, and this is…
Organizations across industries are using automatic text summarization to more efficiently handle vast amounts of information and make better decisions.…
Integrated navigation elements, interactive typography, and digital overprints are three website design trends making waves this month. Let’s take a…
Heavy fonts are essential resources for any designer looking to make an immediate impact. They have the visual strength to…
Picking the AWS vs Azure cloud platform gives the toughest time to any business – be it large or small.…
Salesforce testing is essential for maintaining CRM efficiency and reliability across varied business conditions, such as system updates and high traffic. This practice ensures seamless performance, data security, and user satisfaction. The blog discusses how Salesforce testing not only upholds system integrity but also boosts operational efficiency and compliance, making Salesforce a vital tool for businesses aiming to enhance customer relationships and stay competitive. Learn about the types of Salesforce tests and the strategic benefits of rigorous Salesforce testing to understand why it’s a wise investment for any business using this CRM platform.
The post The Importance of Salesforce Testing for Business Success first appeared on TestingXperts.
When it comes to managing projects or creating new products, the Stage Gate Process is imperative to have in place…
Speaker diarization, an essential process in audio analysis, segments an audio file based on speaker identity. This post delves into…
A React component to apply a drop-in progressive (gradient) backdrop blur to your React applications. The post Progressive Blur Effect…
I am integrating QTP 11.0 autotests with HP ALM 12.20 so I could run them directly from ALM. So I’ve done everything according to Quality Center – QC-QTP Integration:
installed QuickTest_Add-in_for_ALM-QC
set up HP ALM connection to QC
saved the test in Quality Center Test Plan
added Test Resources (Shared Object Repositories, libraries)
added Test to the Test Lab and executed test
But the problem I’ve got when starting test from HP ALM’s test lab is:
BTW: there was a time when the test executed once, but then the problem came back again.
Also tried:
grant access to everyone to the user temp area (%USERPROFILE%AppDataLocalTemp)
Does anyone know what to do?
Extra questions / info to clear up things:
Can you open test files using QTP from ALM/QC Test Plan (as for me, after ‘Save as’ operation, I am trying to open the file and I’ve got the message “Test [test name] does not exist”)
In Test Plan on the tab Test Script of the autotest the message is shown “Can’t load test from C:Users\[user]AppDataLocalTempTD_80876732cc74Test110711071107”, but still when I close it there is a kind of test structure displayed in Keyword View. But when I open this path from QTP everything is fine!
Can anyone please suggust me to solve this issue?
WelDree is a UI to execute Cucumber Scenarios. How this tool development ideation was born? Once a Cucumber feature file is written and implemented, it can be executed using Jenkins, BAT file, and IDEs like IntelliJ & Eclipse. Executing individual scenario from IDE is an easy job for an automation tester. However, if an non-technical
The post WelDree appeared first on Codoid.
I try to configure Jmeter on Ubuntu and I cannot open HTTPS web-page even with installed certificate on Mozilla, HSTS statement appears on web page.
LOGS in Jmeter
2019/07/10 15:07:12 INFO – jmeter.protocol.http.proxy.Proxy: [35494] KeyStore for SSL loaded OK and put host ‘safebrowsing.googleapis.com’ in map with key (safebrowsing.googleapis.com)
2019/07/10 15:07:12 WARN – jmeter.protocol.http.proxy.Proxy: [35494] Problem with SSL certificate for ‘safebrowsing.googleapis.com’? Ensure browser is set to accept the JMeter proxy cert: Received fatal alert: bad_certificate
2019/07/10 15:07:12 WARN – jmeter.protocol.http.proxy.Proxy: [35498] Problem with SSL certificate for ‘incoming.telemetry.mozilla.org’? Ensure browser is set to accept the JMeter proxy cert: Received fatal alert: bad_certificate
HSTS
Certificate in Mozilla
I get the following errror when I use git bash command – however when I run the test in Intellij everything works fine and test starts. Could you help ?
mvn test -Dcucumber.filter.tags=”@desktop”
java.lang.IllegalArgumentException: Input must be set
at org.openqa.selenium.internal.Require.nonNull(Require.java:59)
at org.openqa.selenium.support.ui.FluentWait.<init>(FluentWait.java:97)
at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:77)
at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:46)
at utils.Utils.waitForElement(Utils.java:28)
at pages.LandingPage.acceptConsent(LandingPage.java:21)
Feature file
@desktop
Scenario: Test landing page
Given Customer accepts cookie consent
And I click “OK” button at the bottom of the page
POM
<?xml version=”1.0″ encoding=”UTF-8″?>
<project xmlns=”http://maven.apache.org/POM/4.0.0″
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>Cucumber</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!– https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java –>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.4.0</version>
</dependency>
<!– https://mvnrepository.com/artifact/org.testng/testng –>
<!– https://mvnrepository.com/artifact/org.testng/testng –>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.7.1</version>
<scope>test</scope>
</dependency>
<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-java –>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.8.1</version>
</dependency>
<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-junit –>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
<!– https://mvnrepository.com/artifact/org.assertj/assertj-core –>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.23.1</version>
<scope>test</scope>
</dependency>
<!– https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager –>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>
<!– https://mvnrepository.com/artifact/com.google.guava/guava –>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
<!– https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java –>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.8.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>
<!– https://mvnrepository.com/artifact/org.slf4j/slf4j-simple –>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
<!– https://mvnrepository.com/artifact/org.slf4j/slf4j-api –>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
</dependency>
<!– https://mvnrepository.com/artifact/org.springframework/spring-core –>
<!– https://mvnrepository.com/artifact/org.springframework/spring-core –>
<!– https://mvnrepository.com/artifact/com.opencsv/opencsv –>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.7.1</version>
</dependency>
<!– https://mvnrepository.com/artifact/picocontainer/picocontainer –>
<!– https://mvnrepository.com/artifact/picocontainer/picocontainer –>
<!– https://mvnrepository.com/artifact/picocontainer/picocontainer –>
<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer –>
<!– https://mvnrepository.com/artifact/picocontainer/picocontainer –>
<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer –>
<!– https://mvnrepository.com/artifact/picocontainer/picocontainer –>
<dependency>
<groupId>picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>1.2</version>
</dependency>
<!– https://mvnrepository.com/artifact/de.monochromata.cucumber/reporting-plugin –>
<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-html –>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-html</artifactId>
<version>0.2.7</version>
</dependency>
<!– https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin –>
<!– https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin –>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
</dependency>
<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-java8 –>
<!– https://mvnrepository.com/artifact/io.cucumber/cucumber-core –>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>7.11.2</version>
</dependency>
<!– https://mvnrepository.com/artifact/net.masterthought/maven-cucumber-reporting –>
<!– https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting –>
<!– https://mvnrepository.com/artifact/com.aventstack/extentreports-cucumber4-adapter –>
<!– https://mvnrepository.com/artifact/com.aventstack/extentreports –>
<!– https://mvnrepository.com/artifact/com.relevantcodes/extentreports –>
<!– https://mvnrepository.com/artifact/net.masterthought/maven-cucumber-reporting –>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.7.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<includes>
<include>**/*TestRunner.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.7.5</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>Cucumber</projectName>
<!– optional, per documentation set this to “true” to bypass generation of Cucumber Reports entirely, defaults to false if not specified –>
<skip>false</skip>
<!– output directory for the generated report –>
<outputDirectory>${project.build.directory}</outputDirectory>
<!– optional, defaults to outputDirectory if not specified –>
<inputDirectory>${project.build.directory}/jsonReports</inputDirectory>
<jsonFiles>
<!– supports wildcard or name pattern –>
<param>**/*.json</param>
</jsonFiles>
<!– optional, defaults to outputDirectory if not specified –>
<!– optional, set true to group features by its Ids –>
<mergeFeaturesById>false</mergeFeaturesById>
<!– optional, set true to get a final report with latest results of the same test from different test runs –>
<mergeFeaturesWithRetest>false</mergeFeaturesWithRetest>
<!– optional, set true to fail build on test failures –>
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Intellij configuration where it works
Table of Contents1. Introduction to FunctionsWhat are functions?Why use functions?Defining and calling functions2. Function ArgumentsDefault argumentsKeyword argumentsVariable-length arguments3. Returning Values from FunctionsThe return statementMultiple return valuesReturning None4. Anonymous Functions (Lambda Functions)Syntax and examplesUsing lambda functions as arguments5. Conclusion and Next StepsSummary of key concepts and TechniquesResources for further learning and practice1. Introduction to Functions in PythonFunctions are a way to break up large pieces of code into smaller, more manageable pieces that can be reused and called multiple times throughout a program. In this tutorial, we’ll cover the basics of functions in Python, including what they are, why we use them, and how to define and call them.1.1. What are functions?Functions are named blocks of code that can be called to perform a specific task. They allow you to break up large programs into smaller, more manageable pieces, making your code more organized and easier to read. Functions also help you avoid repeating code, which can save time and reduce errors.1.2. Why use functions?There are several reasons why you might use functions in your code:Code reuse: Once you’ve written a function, you can call it multiple times throughout your program, without having to rewrite the code each time.Organization: Functions allow you to break up your code into smaller, more manageable pieces, making it easier to read and maintain.Modularity: Functions allow you to build complex programs by combining simple, well-defined functions.1.2. Defining and calling functionsIn Python, you define a function using the def keyword, followed by the name of the function, and a set of parentheses. Any arguments to the function are listed inside the parentheses. The function body is indented and contains the code that the function will execute.Here’s an example of a simple function that takes no arguments and simply prints a message:scssCopy codedef say_hello():
print(“Hello, world!”)To call this function, you simply write its name followed by a set of parentheses:scssCopy codesay_hello()
This will execute the code in the function body, printing “Hello, world!” to the console.2. Function ArgumentsIn Python, we can pass arguments to a function by placing them inside the parentheses after the function name. Arguments are input values that are passed to a function when it is called. We can define functions that take one or more arguments, and we can pass arguments to these functions when we call them.Here’s an example:pythonCopy codedef greet(name):
print(“Hello, ” + name + “!”)
greet(“Alice”)
greet(“Bob”)In this example, we define a function called greet that takes a single argument name. The function then prints a message that includes the value of name.When we call the function with greet(“Alice”), the function prints “Hello, Alice!”. Similarly, when we call the function with greet(“Bob”), the function prints “Hello, Bob!”.2.1. Default arguments:In Python, we can also provide default values for function arguments. If we define a function with default values for some of its arguments, those arguments can be omitted when the function is called, and the default values will be used instead.Here’s an example:pythonCopy codedef greet(name, greeting=”Hello”):
print(greeting + “, ” + name + “!”)
greet(“Alice”)
greet(“Bob”, “Hi”)In this example, we define a function called greet that takes two arguments: name and greeting. The greeting argument has a default value of “Hello”. When we call the function with greet(“Alice”), the function prints “Hello, Alice!”. When we call the function with greet(“Bob”, “Hi”), the function prints “Hi, Bob!”.2.2. Keyword arguments:In Python, we can also specify function arguments by keyword, instead of by position. This can be useful when we have functions with many arguments, and we want to make it clear which argument is which.Here’s an example:pythonCopy codedef greet(name, greeting=”Hello”):
print(greeting + “, ” + name + “!”)
greet(greeting=”Hi”, name=”Alice”)In this example, we call the function greet with the arguments name=”Alice” and greeting=”Hi”. Because we specify the arguments by keyword, we can pass them in any order.2.3. Variable-length arguments:In Python, we can define functions that take a variable number of arguments. This can be useful when we don’t know how many arguments a function will need to take.There are two ways to define variable-length arguments in Python: using *args or using **kwargs.2.4. Using *args:We use *args to pass a variable number of arguments to a function. The * indicates that the arguments should be collected into a tuple.Here’s an example:pythonCopy codedef multiply(*args):
result = 1
for arg in args:
result *= arg
return result
print(multiply(2, 3, 4))
print(multiply(5, 6, 7, 8))In this example, we define a function called multiply that takes a variable number of arguments. The function multiplies all of the arguments together and returns the result. When we call the function with multiply(2, 3, 4), the function returns 24. When we call the function with multiply(5, 6, 7, 8), the function returns 1680.2.5. Using **kwargs:We use **kwargs to pass a variable number of keyword arguments. The **kwargs syntax allows us to pass a variable number of keyword arguments to a function. The keyword arguments are passed as a dictionary where the keys are the argument names and the values are the argument values.Here’s an example:pythonCopy codedef print_kwargs(**kwargs):
for key, value in kwargs.items():
print(f”{key} = {value}”)
print_kwargs(name=”Alice”, age=25, city=”New York”)In this example, the print_kwargs function takes a variable number of keyword arguments using **kwargs. The function then iterates over the dictionary of keyword arguments using the items() method and prints each key-value pair.The output of this code will be:makefileCopy codename = Alice
age = 25
city = New York3. Returning Values from FunctionsA function can return a value using the return statement. The value returned by the function can be assigned to a variable or used in an expression.Here’s an example:pythonCopy codedef add_numbers(a, b):
return a + b
result = add_numbers(3, 4)
print(result) # Output: 7In this example, the add_numbers function takes two arguments and returns their sum using the return statement. The function is called with arguments 3 and 4, and the result of the function call is assigned to a variable result. The value of result is then printed to the console.3.1. Multiple return valuesA function can return multiple values using the return statement. In Python, multiple values are returned as a tuple.Here’s an example:pythonCopy codedef get_name_and_age():
name = “Alice”
age = 25
return name, age
result = get_name_and_age()
print(result) # Output: (‘Alice’, 25)In this example, the get_name_and_age function returns two values: a name and an age. The values are returned as a tuple. The function is called and the result is assigned to a variable result. The value of result is then printed to the console.3.2. Returning NoneIf a function does not have a return statement, it returns None by default. None is a special value in Python that represents the absence of a value.Here’s an example:pythonCopy codedef say_hello(name):
print(f”Hello, {name}!”)
result = say_hello(“Alice”)
print(result) # Output: NoneIn this example, the say_hello function takes a name as an argument and prints a greeting. The function does not have a return statement, so it returns None by default. The function is called with the argument “Alice”. The value of the function call is assigned to a variable result, which is then printed to the console. Since the function returns None, the output is also None.4. Conclusion:In Python, functions play a fundamental role in organizing and modularizing code. They allow you to break down complex tasks into smaller, reusable components, making your code more readable, maintainable, and efficient. Throughout this tutorial, we explored various aspects of functions in Python and learned how to define functions, pass arguments, and return values.AuthorVaneesh BehlPassionately writing and working in Tech Space for more than a decade.
 Why you should switch to Cypress for modern web testing?“I think you’ll agree with me when I say…Test your code not your patienceâ€So, What I mean with the above line is that we are in an era where the web is evolving extremely with the deployment of angular.js, react.js, Vue.js and p5.js based web applications. These modern web applications are responsive, communicative(using chatbots) and built on top of material design.We as software automation engineers are traditionally following the approach that has been started a decade ago. Yes, you got it right! I am talking about selenium here. Also, ten years back web wasn’t the same as it is today.Since then web has evolved much, hence the testing should too!Testing is one of the critical processes in application development. The success or failure of the application entirely depends on it. However, website testing is totally different from conventional software testing. Following are some factors that could be a big hurdle to the testing efforts and make web testing more challenging for the testers.Challenges in Modern Web Testing:Dealing with XHR calls and web servicesShort deployment sprints, and major time involved in testingSecurity of dataVery expensive to maintain due to lack of infrastructure for testingDynamic behavior of applications due to modern development frameworksMany more yet to come in the future…These are some problems associated with selenium. Selenium has been a major player in E2E web application testing for a decade now. But the modern web is different today, in order to overcome these shortcomings of selenium cypress comes into the picture here.Why Cypress?Cypress is a JavaScript-based end-to-end testing framework that doesn’t uses selenium at all. It is built on top of mocha which is again a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun.Cypress also uses Chai a BDD / TDD assertion library for node and the browser that can be delightfully paired with any JavaScript testing framework.Well, the developer of Cypress.io Brian Mann, through a survey collected data on testing challenges and addressed most of the shortcomings by developing Cypress. Although Cypress has many handy advantages I want to highlight only those that I found fascinating.Automatic Waiting - Cypress automatically waits for – the DOM to load, the element to become visible, the animation to get completed, the XHR and AJAX calls to be finished and many more. Hence, no need to define implicit and Explicit waits.Real-Time Reloads – Cypress is intelligent enough to know that after saving your test file(xyz_spec.js file) you are gonna run it again. So Cypress automatically triggers the run next to your browser as soon as you press CTRL+S to save your file. Hence, no need to manually trigger the run.Debuggability - Cypress gives you the ability to directly debug your app under test from Chrome Dev-tools, It not only gives you straightforward error messages but also suggests how you should approach them.Some more Advantages of Cypress:Fig 1.0: Cypress FeaturesTo have more insight into Cypress’s Advantages over other automation tools, please read Cypress AdvantagesWhat makes Cypress Different?Architecture – Most testing tools operate by running outside of the browser and executing remote commands across the network. Cypress is the exact opposite. Cypress is executed in the same run loop as your application.Works On Network Layer – Cypress also operates at the network layer by reading and altering web traffic on the fly. This enables Cypress to not only modify everything coming in and out of the browser, but also to change code that may interfere with its ability to automate the browser. Cypress ultimately controls the entire automation process from top to bottom.New Kind Of Testing - Having ultimate control over your application, the network traffic, and native access to every host object unlocks a new way of testing that has never been possible before. Instead of being ‘locked out’ of your application and not being able to easily control it — Cypress instead lets you alter any aspect of how your application works.Test how your application responds to errors on your server by modifying response status codes to 500 so that timers or polls automatically fire without having to wait for the required time in your tests.Shortcuts – Cypress prevents you from being forced to always ‘act like a user’ to generate the state of a given situation. That means you do not have to visit a login page, type in a username and password and wait for the page to load and/or redirect for every test you run. Cypress gives you the ability to take shortcuts and programmatically log in.Shift left paradigm in CypressInstalling CypressInstalling cypress is a fairly easy task. The only thing you need to have is node.js installed in your machine and then it’s all about two npm commands -1. npm init2. npm install cypress –save-devThe first command will create a package.json file and the second command will install cypress as a ‘devDependencies’ array in your package descriptor (package.json) file.Installing Cypress will take around 2 to 3 mins based on your network speedCypress has now been installed to your ./node_modules directory. Once you have done with the installation part, you are gonna open Cypress for the first time by executing this command at the location where you have your package.json file -./node_modules/.bin/cypress openTo view the full installation video click here. This will open cypress GUI like -Fig 1.1: GUI-based Cypress Test RunnerCypress comes with its own folder structure, this folder automatically gets generated when you open Cypress for the first time at that location. It comes with ready-made recipes that show you how to test common scenarios in Cypress.Fig 1.2: Cypress folder structureWe keep our test data in JSON format inside the fixture folder and writes test inside the integration folder following the same naming convention. Any custom command will come under the support folder.Writing Your First Test using CypressLet’s create a new file kitchensink_spec.js in the cypress/integration folder. Open up your favorite IDE and add the code below to our kitchensink_spec.js test file./** * @author Shivam Bharadwaj * @description Cypress Demo */
//This is where your test suite startsdescribe(‘My First Test’, function () {
//This function will execute before each test (i.e it()) beforeEach(function () { //Visiting the url cy.visit(‘https://example.cypress.io’) })
//Here you actually writes your test (it() is similar to @Test annotaion of TestNG) it(‘Visits the Kitchen Sink’, function () {
//Click on type button cy.contains(‘type’).click()
// Should be on a new URL which includes ‘/commands/actions’ cy.url().should(‘include’, ‘/commands/actions’)
// Get an input, type into it and verify that the value has been updated cy.get(‘.action-email’) .type(‘fake@email.com’) .should(‘have.value’, ‘fake@email.com’) })})Code Explanation -Line 7 is creating a test suite with the name ‘My First Test’. Line 10 is creating a function that runs before each test. Line 12 with the simple cy.visit command passing the URL we want to visit. With line 16 we are actually writing a test having the name ‘Visits the Kitchen Sink’ And inside it at line 19, we are kind of making an assertion first, and then if DOM contains a ‘type’ word on UI it triggers a click event on it.At line 22 we are verifying that after clicking the new URL should contain /commands/cations. Finally in line 25 to 27 we first finding the element by its class name, typing fake@email.com in it and finally verifying that the correct value is typed.To view the short video of the code click hereOutput -Wow!! It took only 7.89 seconds for the application to load, type some values and verify the assertion. It’s incredible!!Fig 1.4: Console outputusing cypress we can automatically travel back in time by just hovering over the event within our application under test in such a way that it takes you to that moment where the application was at the time of the event triggered. But as we hover over the CONTAINS, Cypress reverts back to the URL that was present when our snapshot was taken.Notice there is also a funny looking Log called: (PAGE LOAD) followed by another entry for (NEW URL). Neither of these was a command that we issued rather Cypress itself will log out important events from your application when they occur.As you can see this is the console view at the bottom of the image(Fig1.4) where you can find all the information about the event like command, selector, value, matched elements, and yielded.Congratulations!!! You have tested your app with Cypress.ConclusionHence, we might think to switch our tactics and use Cypress as our primary E2E tool. It works as expected and makes our lives a lot easier.I have used Cypress way too little to like it very much and think this is the tool we required.In any way do try Cypress.To know more about cypress refer to the links below -Referencesexample source codeCypress.io documentationhttps://github.com/cypress-io/cypressGuest Author:Shivam BharadwajSay Hi on Twitter
1. Introduction to Selenium1.1 What is Selenium?Selenium is an open-source test automation framework that allows you to automate web browsers. It provides a suite of tools and libraries for different automation needs. Selenium supports multiple programming languages, including Java, Python, C#, etc., making it a versatile choice for automating web applications.1.2 Selenium ComponentsSelenium consists of the following components:1. Selenium WebDriver: It is the core component of Selenium and provides a programming interface to interact with web browsers. WebDriver allows you to automate browser actions such as opening URLs, filling forms, clicking buttons, and more.2. Selenium IDE: It is a record and playback tool for creating automated test cases. Selenium IDE is a browser extension that allows you to record user interactions with a web application and generate test scripts.3. Selenium Grid: It is a tool used for distributed test execution. Selenium Grid enables you to run tests on multiple machines or browsers in parallel, making it suitable for large-scale test automation.1.3 Advantages of SeleniumSelenium offers several advantages for test automation:1. Cross-browser compatibility: Selenium supports multiple web browsers such as Chrome, Firefox, Safari, and Internet Explorer, allowing you to test your web application on different platforms.2. Multiple language support: Selenium supports various programming languages, giving you the flexibility to choose the language you are comfortable with for test automation.3. Wide community support: Selenium has a large and active community of users and contributors who share knowledge, provide support, and contribute to the development of the framework.4. Extensibility: Selenium can be extended through custom libraries, frameworks, and plugins, allowing you to enhance its functionality and integrate it with other tools.5. Integration with test frameworks: Selenium can be integrated with popular test frameworks such as TestNG and JUnit, enabling you to leverage advanced features like test management, reporting, and data-driven testing.1.4 Limitations of SeleniumWhile Selenium is a powerful test automation tool, it also has some limitations:1. Limited support for desktop applications: Selenium is primarily designed for automating web applications and has limited support for automating desktop applications.2. No built-in support for image-based testing: Selenium does not provide native capabilities for image-based testing, making it challenging to verify the visual aspects of a web application.3. Complex setup for distributed testing: Setting up and configuring Selenium Grid for distributed testing requires additional effort and technical knowledge.4. Maintenance overhead: As web applications evolve and change, test scripts written with Selenium may require maintenance to accommodate updates in the application’s structure and behavior.1.5 Selenium vs. Other Automation ToolsSelenium offers several advantages over other automation tools:1. Open-source: Selenium is an open-source framework, which means it is free to use and has a large and active community of contributors.2. Cross-browser compatibility: Selenium supports multiple browsers, making it suitable for testing web applications on different platforms.3. Language support: Selenium supports multiple programming languages, allowing users to write test scripts in their preferred language.4. Extensibility: Selenium can be extended through custom libraries and frameworks, providing flexibility and customization options.5. Integration with test frameworks: Selenium can be easily integrated with popular test frameworks like TestNG and JUnit, enabling users to leverage advanced testing features.2. Introduction to Selenium WebDriver2.1 Introduction to WebDriverSelenium WebDriver is the primary component of the Selenium framework that allows you to automate browser actions and interact with web elements. WebDriver provides a programming interface to write test scripts in various programming languages such as Java, Python, C#, etc. These test scripts can then be executed on different web browsers to automate testing tasks.2.2 WebDriver ArchitectureThe architecture of WebDriver consists of the following key components:1. Language Bindings: WebDriver provides language-specific bindings that enable you to write test scripts in your preferred programming language.2. WebDriver API: The WebDriver API provides methods and classes to interact with web browsers, locate and manipulate web elements, and perform various browser actions.3. Browser Drivers: WebDriver requires a specific browser driver to establish a connection with the target browser. Each browser (e.g., Chrome, Firefox, Safari) has its own driver that needs to be downloaded and configured.4. Native Events: WebDriver uses native events to simulate user interactions with web elements, ensuring accurate automation of actions like clicking, typing, etc.5. JSON Wire Protocol: WebDriver communicates with the browser drivers using the JSON Wire Protocol, which defines a standard way to exchange commands and responses between the WebDriver API and the browser drivers.2.3 WebDriver-Supported BrowsersWebDriver supports a wide range of web browsers, including but not limited to:1. Google Chrome: ChromeDriver2. Mozilla Firefox: GeckoDriver3. Microsoft Edge: EdgeDriver4. Apple Safari: SafariDriver (limited support)5. Opera: OperaDriver6. Internet Explorer: InternetExplorerDriver (deprecated)Each browser requires its respective driver executable, which needs to be downloaded and placed in the system’s PATH or configured to the WebDriver instance.2.4 Setting Up WebDriverTo set up WebDriver for test automation, follow these general steps:1. Choose a programming language: Determine which programming language you want to use for writing WebDriver scripts. Popular choices include Java, Python, and C#.2. Download the browser driver: Visit the official Selenium website or the browser driver’s respective website to download the appropriate driver for your target browser. Ensure that you download the version compatible with your browser version.3. Configure the browser driver: Set the path to the browser driver executable in your project configuration or system’s PATH environment variable.4. Set up the WebDriver library: Add the necessary WebDriver library or dependencies to your project. You can typically do this by adding the relevant Maven or Gradle dependencies or by including the WebDriver JAR files manually.5. Initialize the WebDriver instance: In your test script, create an instance of the WebDriver using the appropriate driver class for the desired browser (e.g., ChromeDriver, FirefoxDriver).6. Write test scripts: Use the WebDriver API to write test scripts, which involve actions like navigating to URLs, interacting with web elements, and validating expected behaviors.7. Execute test scripts: Run your WebDriver test scripts to execute the automation tasks on the target browser.Remember to handle exceptions, manage waits and synchronization, and implement best practices for writing maintainable and robust WebDriver test scripts. 3. How does Selenium WebDriver Work? Here’s a high-level overview of how Selenium works:1. Selenium WebDriver:At the core of Selenium is WebDriver, which provides a programming interface to interact with web browsers. WebDriver allows you to automate browser actions such as opening URLs, filling forms, clicking buttons, and more.WebDriver communicates with the browser through a browser-specific driver. For example, ChromeDriver for Google Chrome, GeckoDriver for Mozilla Firefox, etc. These drivers act as intermediaries between WebDriver and the browser, enabling communication and control.2. Browser Automation:Selenium WebDriver uses the browser driver to establish a connection with the target browser. This connection allows WebDriver to control the browser and execute commands.When you execute a command using WebDriver (e.g., navigating to a URL, clicking an element), WebDriver sends the corresponding command to the browser driver.The browser driver translates the command into browser-specific actions and sends them to the browser for execution.The browser performs the requested action (e.g., opens the URL, clicks the element), and the result is sent back to the browser driver.3. Locating Web Elements:Selenium provides various methods to locate web elements on a web page, such as by ID, name, class name, CSS selector, XPath, etc.Once a web element is located, WebDriver can perform actions on it, such as clicking, typing, getting text, etc.4. Synchronization and Waits:Web applications often have dynamic elements that load asynchronously or have animations. To handle such scenarios, Selenium provides synchronization techniques and wait mechanisms.You can use implicit waits or explicit waits to wait for specific conditions or elements to be present, visible, clickable, etc. before performing actions on them.5. Assertions and Verifications:Selenium allows you to perform assertions and verifications to validate the expected behavior of a web application.You can verify element presence, text content, attribute values, page titles, URLs, and more.6. Test Reporting and Logging:Selenium provides options for generating test reports and logging test execution details.You can integrate Selenium with test frameworks like TestNG or JUnit to generate detailed test reports and manage test execution.Overall, Selenium provides a powerful set of tools and APIs that enable you to automate web testing and perform a wide range of actions on web browsers. It allows you to simulate user interactions, validate expected behavior, and integrate with other tools and frameworks for efficient test automation.Next >> What are Selenium Locators?AuthorVaneesh BehlPassionately working as an Automation Developer for more than a decade.