com.github.automatedowl:selenium-download-kpi

Selenium extension for Java which provides KPIs of file downloads.

License

License

Categories

Categories

Auto Application Layer Libs Code Generators
GroupId

GroupId

com.github.automatedowl
ArtifactId

ArtifactId

selenium-download-kpi
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

com.github.automatedowl:selenium-download-kpi
Selenium extension for Java which provides KPIs of file downloads.
Project URL

Project URL

https://github.com/AutomatedOwl
Source Code Management

Source Code Management

https://github.com/AutomatedOwl/selenium-download-kpi

Download selenium-download-kpi

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.automatedowl/selenium-download-kpi/ -->
<dependency>
    <groupId>com.github.automatedowl</groupId>
    <artifactId>selenium-download-kpi</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.automatedowl/selenium-download-kpi/
implementation 'com.github.automatedowl:selenium-download-kpi:1.0.3'
// https://jarcasting.com/artifacts/com.github.automatedowl/selenium-download-kpi/
implementation ("com.github.automatedowl:selenium-download-kpi:1.0.3")
'com.github.automatedowl:selenium-download-kpi:jar:1.0.3'
<dependency org="com.github.automatedowl" name="selenium-download-kpi" rev="1.0.3">
  <artifact name="selenium-download-kpi" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.automatedowl', module='selenium-download-kpi', version='1.0.3')
)
libraryDependencies += "com.github.automatedowl" % "selenium-download-kpi" % "1.0.3"
[com.github.automatedowl/selenium-download-kpi "1.0.3"]

Dependencies

compile (7)

Group / Artifact Type Version
org.junit.platform : junit-platform-launcher jar 1.2.0
org.junit.jupiter : junit-jupiter-engine jar 5.2.0
org.junit.jupiter : junit-jupiter-api jar 5.2.0
org.seleniumhq.selenium : selenium-api jar 3.12.0
org.seleniumhq.selenium : selenium-chrome-driver jar 3.12.0
org.seleniumhq.selenium : selenium-support jar 3.5.3
io.qameta.allure : allure-java-commons jar 2.6.0

test (1)

Group / Artifact Type Version
io.qameta.allure : allure-junit5 jar 2.6.0

Project Modules

There are no modules declared in this project.

selenium-download-kpi

Selenium extension for Java which provides KPIs of file download. Currently, the library supports Chromedriver. It would allow you:

  • To define your download folder both globally and locally in one code line.
  • Given a file name, web element and timeout, you would be able to download a file and verify its success.
  • Logging the download bandwidth in Mbps and attaching it to Allure report.
  • Assertion of download bandwidth, where you define a numeric threshold for passing/failing the test.

Setting up your test

To easily define your download folder, create a new instance of SeleniumDownloadKPI object, with the download folder path supplied as String parameter.

After initialization of SeleniumDownloadKPI object, and before initializing your Chromedriver object, use generateDownloadFolderCapability() method to get ChromeOptions object which contains your download folder, then pass it to Chromedriver constructor.

    private SeleniumDownloadKPI seleniumDownloadKPI;

    @BeforeEach
    void setUpTest() {
        seleniumDownloadKPI =
             new SeleniumDownloadKPI("/tmp/downloads");
        ChromeOptions chromeOptions =
                seleniumDownloadKPI.generateDownloadFolderCapability();
        driver = new ChromeDriver(chromeOptions);
    }

Example of file download with bandwidth attachment:

The method fileDownloadKPI() receives three parameters:

WebElement object: adamInternetPage.getFileDownloadLink() returns a WebElement of download link.

String object: "SpeedTest_16MB.dat" describes the file name which intended to be downloaded.

boolean deleteFile: Indicates whether to delete or keep the file after the download finishes.

The method would perform a download using a default timeout of five minutes, and would also throw an exception in case of unsuccessful download.

    @Test
    void downloadAttachTest() throws InterruptedException {
        adamInternetPage.navigateToPage(driver);
        seleniumDownloadKPI.fileDownloadKPI(
                adamInternetPage.getFileDownloadLink(), "SpeedTest_16MB.dat", true);
        waitBeforeClosingBrowser();
    }

Example of file download with bandwidth attachment (custom timeout):

Alternative variation of fileDownloadKPI() method. The method would act exactly the same as described above, just with a custom download timeout of one minute passed as third argument (in milliseconds).

    @Test
    void downloadAttachCustomTimeoutTest() throws InterruptedException {
        adamInternetPage.navigateToPage(driver);
        seleniumDownloadKPI.fileDownloadKPI(
                adamInternetPage.getFileDownloadLink(),
                "SpeedTest_16MB.dat", 60000, true);
        waitBeforeClosingBrowser();
    }

Example of file download with attachment and assertion:

The method fileDownloadAssertKPI() receives four parameters:

WebElement object: adamInternetPage.getFileDownloadLink() returns WebElement of download link.

String object: "SpeedTest_16MB.dat" describes the file name which intended to be downloaded.

Long value '5' is the Mbps threshold for the file download. If the download bandwidth would be less than 5Mbps, exception would be thrown.

boolean deleteFile: Indicates whether to delete or keep the file after the download finishes.

It also uses a default download timeout of five minutes.

    @Test
    void downloadAssertTest() throws InterruptedException {
        adamInternetPage.navigateToPage(driver);
        seleniumDownloadKPI.fileDownloadAssertKPI(
                adamInternetPage.getFileDownloadLink(),
                "SpeedTest_16MB.dat", 5, true);
        waitBeforeClosingBrowser();
    }

Example of file download with attachment and assertion (custom timeout):

Alternative variation of fileDownloadAssertKPI() method. The method would act exactly the same as described above, just with a custom download timeout of one minute passed as fourth argument (in milliseconds).

    @Test
    void downloadAssertTest() throws InterruptedException {
        adamInternetPage.navigateToPage(driver);
        seleniumDownloadKPI.fileDownloadAssertKPI(
                 adamInternetPage.getFileDownloadLink(),
                 "SpeedTest_16MB.dat", 5, 60000, true);
        waitBeforeClosingBrowser();
    }

Sanpshot of file download with bandwidth attachment in Allure report:

Bandwidth Attachment

Sanpshot of bandwidth exception:

Bandwidth Exception

Sanpshot of bandwidth logging:

Bandwidth Logging

Maven repository

<dependency>
  <groupId>com.github.automatedowl</groupId>
  <artifactId>selenium-download-kpi</artifactId>
  <version>1.0.3</version>
</dependency>

Versions

Version
1.0.3
1.0.2
1.0.1
1.0.0