How to perform Test Automation with CircleCI
On This Page Understanding CircleCIJune 04, 2026 · 11 min read · Testing Guide
Automating tests within a Uninterrupted Integration pipeline is crucial for present reliable software expeditiously. CircleCI volunteer a rich platform to run automated tests on every code change, helping teams catch issues early and maintain code quality. CircleCI is a popular continuous integration and continuous delivery (CI/CD) platform that automatise software builds, tests, and deployment, enable faster and more reliable development workflows. Why integrate your Test Automation Suite with CircleCI? This guidebook explain how to set up test mechanisation with CircleCI and leverage BrowserStack ’ s real device cloud to run cross-browser test seamlessly. CircleCI is a cloud-based platform designed to automate the. It helps development teams build, test, and deploy applications expeditiously by automating repetitive tasks and enabling rapid feedback on code changes. At its core, CircleCI scat your codification through a series of customizable steps delimit in a contour file (.circleci/config.yml). These steps can include checking out your source code, installing dependence, running tests, and deploying your application. Key construct in CircleCI include: By automatise your exam automation suite within CircleCI, you ensure that every codification update is formalize consistently and quickly, trim errors and improving. Read More: In many organizations, multiple Test Automation Engineers employment on the like labor, frequently update mechanisation code. Manually running tests after every alteration is tedious and prone to errors, such as forgetting to activate builds, which can let bugs slip through and disrupt the workflow. By integrating test automation with CircleCI, every commit and pull request automatically triggers tryout, with effect visible directly in GitHub. This insure former detection of topic, boosts confidence in the exam entourage, and enable faster fixes, helping maintain code lineament throughout development. Additional benefits include: By integrating your test mechanization suite with CircleCI, teams improve reliability, speed, and overall software quality, create a more efficient and scalable development process. For reliable and real twist testing, integrating with CircleCI further enhances your test coverage and speeds up release cycles. Before you commence setting up test automation with CircleCI, make sure you have: Read More: Once your prerequisites are in place, postdate these steps to configure and run your trial mechanisation suite using CircleCI. Step 1:Sample Test Automation Code SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses. Create a sample test automation code to later integrate with CircleCI. For the purpose of this demo, a bare test suit is created here that opens a website using TestNG. Below are the contents of theexamination class, pom.xml, and testng.xml files. NewTest.java pom.xml testng.xml Step 2:Create a free account on CircleCI CircleCI proffer a cloud build platform wherein you can easily get started by creating a free account. Please mention the limitations of the complimentary tier. Click on theStart Building for Free button. This will take you to a page where you will demand to select the account apply which you will create your CircleCI account. For ease of frame-up, you can choose to integrate your GitHub report. Click on Sign up with GitHuband it will link to your GitHub organization if it is already logged in. Else login to your Github organization when prompted. Once this is make, Github asks for authorization to allow access to CircleCI to desegregate with your report. Click onAuthorize CircleCI Step 3:Select your organization Once the login is completed, you will be asked to choose your GitHub organization. Select the one you want to link with CircleCI. Once done, the homepage of CircleCI opens. This will have your repositories populated. The leftover pane offers button forDashboards, Projects, Organization Settings,and Plan. For this demo, let & # 8217; s use theCircleCI_Selenium_Demorepository. Step 4:Create a Project Click on Set Up Projectfor the repository that holds your test mechanization codification. This will open a dialogue box with the following options. Select the nonpayment branch from which you want to run the project. CircleCI relies on a config.yml file that have all the configuration of the pipeline. Here adding a sampleconfig.yml fileto this project by choosing theHello Worldtemplate after selecting theFast option. If you already are familiar with creating aconfig.yml, you can create one in your tryout mechanisationrepo. Below is theconfig.ymlthat has been used for this labor. config.yml Note that upon every commit, CircleCI will activate a new run of the pipeline automatically. Also, when you use the Hello World template for create a samplingconfig.ymlfile, you would receive noticed that it would automatically create a new branch in GitHubcircleci-project-setup. You can continue to edit yourconfig.ymlfile in the leg and merge it backward onto the main branch when needed. The CircleCI project can be configure to run the examination from any branch on the repo. It can be noted that for every PR elevate on Github, a new run is triggered on CircleCI and the status of the run would get updated in GitHub. This serves as an extra check while unite PRs. This is how you can configure and run our test automation use CircleCI. CircleCI relies on the config.yml file to specify all workflows, occupation, and integrations. You can integrate BrowserStack directly within this form to run exam on real devices. This enables access to 3500+ real device-browser combinations for comprehensive and support democratic automation frameworks such as Selenium, Cypress, Playwright, and Puppeteer. There are some variables likegrid config, username, and access key, that we will need to set in order to get the integration to work. Configuration ofcircle.ymlfile for Selenium Tests CircleCI surroundings variable in your code can be seen as below: To ensure reliable, maintainable, and efficient test automation when using CircleCI with BrowserStack, consider the following best practices: Integrating your test mechanization suite with CircleCI streamlines the testing procedure by automating test execution on every commit or pull postulation. It ensures faster feedback, improves collaboration across teams, and helps catch subject betimes in the package development rhythm. By extending this setup with, you can run trial across a wide orbit of real device-browser combination, further boosting and. Together, CircleCI and BrowserStack enable a robust, scalable, and effective continuous testing pipeline that supports faster and more confident release. # Ask-and-Contributeabout this topic with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.How to perform Test Automation with CircleCI
Overview
Understanding CircleCI
Why integrate your Test Automation Suite with CircleCI?
Prerequisites
How to perform Test Automation with CircleCI
package tests; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; public class NewTest {public ChromeDriver driver; @ BeforeTest public nothingness beforeClass () {System.setProperty (`` webdriver.chrome.driver '', `` chromedriver.exe ''); driver = new ChromeDriver ();} @ Test public void openWebsite () {driver.get (`` https: //www.google.com/ '');} @ AfterTest public void afterClass () {driver.close ();}}& lt; 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 '' & gt; & lt; modelVersion & gt; 4.0.0 & lt; /modelVersion & gt; & lt; groupId & gt; mavenPackage & lt; /groupId & gt; & lt; artifactId & gt; MavenProject & lt; /artifactId & gt; & lt; version & gt; 0.0.1-SNAPSHOT & lt; /version & gt; & lt; dependency & gt; & lt;! -- Selenium -- & gt; & lt; dependency & gt; & lt; groupId & gt; org.seleniumhq.selenium & lt; /groupId & gt; & lt; artifactId & gt; selenium-java & lt; /artifactId & gt; & lt; variant & gt; 4.2.0 & lt; /version & gt; & lt; /dependency & gt; & lt;! -- TestNG -- & gt; & lt; colony & gt; & lt; groupId & gt; org.testng & lt; /groupId & gt; & lt; artifactId & gt; testng & lt; /artifactId & gt; & lt; version & gt; 7.4.0 & lt; /version & gt; & lt; range & gt; test & lt; /scope & gt; & lt; /dependency & gt; & lt; /dependencies & gt; & lt; build & gt; & lt; plugins & gt; & lt; plugin & gt; & lt; groupId & gt; org.apache.maven.plugins & lt; /groupId & gt; & lt; artifactId & gt; maven-compiler-plugin & lt; /artifactId & gt; & lt; version & gt; 3.10.1 & lt; /version & gt; & lt; configuration & gt; & lt; germ & gt; 1.8 & lt; /source & gt; & lt; target & gt; 1.8 & lt; /target & gt; & lt; /configuration & gt; & lt; /plugin & gt; & lt; plugin & gt; & lt; groupId & gt; org.apache.maven.plugins & lt; /groupId & gt; & lt; artifactId & gt; maven-surefire-plugin & lt; /artifactId & gt; & lt; version & gt; 2.20 & lt; /version & gt; & lt; configuration & gt; & lt; suiteXmlFiles & gt; & lt; suiteXmlFile & gt; testng.xml & lt; /suiteXmlFile & gt; & lt; /suiteXmlFiles & gt; & lt; /configuration & gt; & lt; /plugin & gt; & lt; /plugins & gt; & lt; /build & gt; & lt; /project & gt;
& lt;! DOCTYPE suite SYSTEM `` http: //testng.org/testng-1.0.dtd '' & gt; & lt; suite name= '' Suite '' parallel= '' false '' & gt; & lt; test name= '' Test '' & gt; & lt; form & gt; & lt; class name= '' tests.NewTest '' / & gt; & lt; /classes & gt; & lt; /test & gt; & lt;! -- Test -- & gt; & lt; /suite & gt; & lt;! -- Suite -- & gt;
version: 2 task: form: docker: # specify the version you desire hither - image: circleci/openjdk:8-jdk working_directory: ~/circleCI_Selenium_Demo environment: # Customize the JVM maximum heap limit MAVEN_OPTS: -Xmx3200m steps: - checkout # Download and cache addiction - restore_cache: keys: - v1-dependencies- {{checksum `` pom.xml ''}} # fallback to using the latest cache if no exact match is found - v1-dependencies- - run: mvn dependance: go-offline - run: name: Install latest adaptation of ChromeDriver Sample bid: | sudo wget -q -O - https: //dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - sudo sudo sh -c 'echo `` deb [arch=amd64] http: //dl.google.com/linux/chrome/deb/ stable master '' & gt; & gt; /etc/apt/sources.list.d/google.list' sudo apt-get update sudo apt-get install google-chrome-unstable - run: gens: Install late version of ChromeDriver Sample dictation: | sudo wget https: //chromedriver.storage.googleapis.com/2.31/chromedriver_linux64.zip sudo unzip -o chromedriver_linux64.zip sudo rm chromedriver_linux64.zip sudo mv chromedriver /usr/bin/ sudo chmod 777 /usr/bin/chromedriver sudo apt-get install libxi6 libgconf-2-4 sudo apt-get -y install xvfb gtk2-engines-pixbuf sudo apt-get -y establish xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable sudo apt-get install xvfb sudo apt-get -y install imagemagick x11-apps - run: name: Running X virtual framebuffer command: Xvfb :0 -ac & amp; - run: gens: Run Tests bidding: | export DISPLAY=:99 - save_cache: paths: - ~/.m2 key: v1-dependencies- {{checksum `` pom.xml ''}} # run examination! - run: mvn clean test - store_artifacts: path: target/surefire-reports destination: tr1 - store_test_results: way: target/surefire-reportsIntegrating Browserstack with CircleCI
machine: surround: BROWSERSTACK_USERNAME: “ & lt; user-name & gt; ” BROWSERSTACK_ACCESS_KEY: `` & lt; access-key & gt; j '' BROWSERSTACK_LOCAL: false BROWSERSTACK_LOCAL_IDENTIFIER: `` identifier ''
String username = System.getenv (`` BROWSERSTACK_USERNAME ''); String accessKey = System.getenv (`` BROWSERSTACK_ACCESS_KEY ''); String browserstackLocal = System.getenv (`` BROWSERSTACK_LOCAL ''); String browserstackLocalIdentifier = System.getenv (`` BROWSERSTACK_LOCAL_IDENTIFIER ''); DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (`` os '', `` Windows ''); capabilities.setCapability (`` browser '', `` chrome ''); capabilities.setCapability (`` browserstack.local '', browserstackLocal); capabilities.setCapability (`` browserstack.localIdentifier '', browserstackLocalIdentifier); driver = new RemoteWebDriver (new URL (`` https: // '' + username + ``: '' + accessKey + `` @ hub.browserstack.com/wd/hub ''), capabilities);
Best Practices for Test Automation with CircleCI and BrowserStack
Conclusion
Related Guides
Automate This With SUSA
Test Your App Autonomously