Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The data rates in the ChromiumNetworkConditions.cs properties are incorrect #9461

Closed
TridentTrue opened this issue May 10, 2021 · 4 comments
Closed
Labels

Comments

@TridentTrue
Copy link

🐛 Bug Report

The data rate in the tooltips for DownloadThroughput and UploadThroughput of ChromiumNetworkConditions.cs appear to be incorrectly listed as kb/second when it should be bytes per second.

To Reproduce

For any basic test using the ChromeDriver, initialize the driver's NetworkConditions property with a ChromeNetworkConditions object with DownloadThroughput and UploadThroughput in kb/s, then run the test while observing data transfer rate using your preffered monitoring software e.g. WireShark

Expected behavior

Chrome driver throttles network rates at the speeds that were defined in kb/s.

Test script or set of commands reproducing this issue

If for example you supply the download with a value of 10000 then during the actual test it will show a rate of 0.08Mbps rather than the expected 10Mbps.

To get the desired 10Mbps throughput you would have to instead set the download value to 1250000.

public class NetworkConditionsTests
{
    public void IncorrectNetworkThrottleTest()
    {
        int latencyInMilliseconds = 20;
        long downloadLimitMbps = 10;
        long uploadLimitMbps = 5;

        ChromeDriver driver = new ChromeDriver()
        {
            NetworkConditions = new ChromeNetworkConditions()
            {
                Latency = new TimeSpan(0, 0, 0, 0, latencyInMilliseconds),
                DownloadThroughput = downloadLimitMbps * 1000, // Mbps to kb/s
                UploadThroughput = uploadLimitMbps * 1000, // Mbps to kb/s
                IsOffline = false,
            }
        };

        driver.Navigate().GoToUrl("https://github.com/SeleniumHQ/selenium");

        var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 30));
        wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.ClassName("repository-content")));
    }

    public void CorrectNetworkThrottleTest()
    {
        int latencyInMilliseconds = 20;
        long downloadLimitMbps = 10;
        long uploadLimitMbps = 5;

        ChromeDriver driver = new ChromeDriver()
        {
            NetworkConditions = new ChromeNetworkConditions()
            {
                Latency = new TimeSpan(0, 0, 0, 0, latencyInMilliseconds),
                DownloadThroughput = downloadLimitMbps * 125000, // Mbps to bytes per second
                UploadThroughput = uploadLimitMbps * 125000, // Mbps to bytes per second
                IsOffline = false,
            }
        };

        driver.Navigate().GoToUrl("https://github.com/SeleniumHQ/selenium");

        var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 30));
        wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.ClassName("repository-content")));
    }
}

Environment

OS: Windows 10
Browser: Google Chrome
Browser version: 89.0.4389.2300
Browser Driver version: ChromeDriver 89.0.4389.2300
Language Bindings version: C# 3.141.0
Selenium Grid version (if applicable): N/A

@ghost ghost added the needs-triaging label May 10, 2021
@jimevans
Copy link
Member

@TridentTrue What's the actual issue here, that the IntelliSense documentation comments say the values are defined as kb/s; or that the command should be using kb/s as documented and implemented in the chromedriver source are using bytes/s?

@TridentTrue
Copy link
Author

@jimevans I would imagine it's more likely that the intellisense is incorrect rather than the actual implementation, especially if it's just plugging the parameters straight into the chrome API. May also break some users existing tests if the numbers were tweaked but I don't know how heavily the feature is used.

jimevans added a commit that referenced this issue Sep 29, 2021
@jimevans
Copy link
Member

Fixed doc string in cd12f66.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants