It will help you to have a Selenium test in azure pipelines also helps to automatically build, test, and deploy your projects, with Continuous Integration, upon various production environments. So your Selenium automation test scripts can run successfully on Azure Pipeline.
Why we need Azure pipelines for integration
- We can have an automated way of running our regression test. Whenever we have any changes to our Version Control System repository and we can have our test run in parallel along with the project build. So that we can identify any bugs or defects even when there is a small change of functionality or code So that’s the reason we can integrate Selenium test in azure pipelines.
Prerequisites
- Java as the programming language
- TestNG as the assertion framework
- Maven as the build tool
- WebDriver as the browser automation tool
- IntelliJ as the IDE
Some dependencies we use in this framework
- To read data from an excel file we need Apache POI maven dependency
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
- For testNg.xml dependency
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>compile</scope>
</dependency>
- For Generating Extent Report dependency
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
Handle chrome browser in Headless mode
- The headless option will tell to Google Chrome to execute in headless mode. The window-size is a way to control the responsiveness (and allows your site be displayed, like a mobile site, if you have not set a window size). Now we handle it with code,
- We specify the path to our chrome driver
System.setProperty("webdriver.chrome.driver", OpenBrowser.CHROME_DRIVER_PATH);
Properties prop = new Properties();
- Now we have to do is to create a Web Driver object, and set the Chrome Driver path and some arguments
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless"); //for headless mode
options.addArguments("--window-size=800,600");//The invisible browser window is only 800x600 in size
options.addArguments("start-maximized"); // open Browser in maximized mode
options.addArguments("disable-infobars"); // disabling infobars
options.addArguments("--disable-extensions"); // disabling extensions
options.addArguments("--disable-gpu"); // applicable to windows os only
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("--no-sandbox");
driver = new ChromeDriver(options);
Now We Go to Azure DevOps For Pipeline
- Go to Microsoft azure url – https://dev.azure.com and sign in the microsoft account.
- Click on start free. After you see yourself in Azure devops page.
Creating Azure Pipeline
- Login to your azure devops account ,create a organization and project.

2. Click “pipeline” option from left side menu

3. Click “Create Pipeline” button

4. Click the text “Use the classic editor” and create a connection with your source code tool whatever you are using and select the selenium project. Click “Continue”.

5. Select the “Maven” template and click “Add”.

6. Add the report (so that you can download the reports like html , emailable reports etc from pipeline)” in Publish build Artifacts” task to publish the report.

- Path to publish – provide the path of your result folder which you want to publish.
- Display Name – Provide task name.
- Maven POM file – Give name of POM file (select the … dots and select the POM file)
- Goal(s) – test
- Publish to azure pipelines – Ensure checkbox is checked
- Test run title – provide test run title name
- Test results files – provide the path of test result file (i am using default)

7. Click “Save and queue” button, then click “Save and run”.

8. Click on Agent Job 1 ,to see the job logs

Reports and Artifact
- After successful completion , click on ” Tests” tab to see the results in azure pipeline.

- Click “Published” link to see the artifacts.

- You can find the report here which you can download and use.

Summary of Report

References
