首页 > 解决方案 > 为什么下一个按钮要花这么长时间才能按下?

问题描述

好吧,很简单,我在 C# 中有一个 selenium 脚本,您从下拉框中选择一个名称,选择日期并逐页计算结果的数量。现在有人可以帮我加快这个过程,因为单击下一个按钮进入下一页几乎需要 5 秒钟。

这是我的代码:

int entityCount = 0;
int totalCount = 0;

try
{
    System.Threading.Thread.Sleep(5000);
    while (_AuditRep.nextButton.Enabled && _AuditRep.nextButton.Displayed)
    {
        System.Threading.Thread.Sleep(5000);
        _AuditRep.nextButton.Click();
        entityCount += _AuditRep.AuditResultsByEntity("Users").Count;
        totalCount += _AuditRep.AuditTotalResults.Count;

    }
    if (entityCount != totalCount)
    {
        Assert.Fail("The count of Drivers is " + entityCount + " whereas "
            + "the total count is " + totalCount);
    }
    else
    {
        Console.WriteLine("The count of entity Drivers is " + entityCount + " and "
            + "the total count is " + totalCount);
    }
}
catch
{
    if (_AuditRep.AuditResultsByEntity("Users").Count != _AuditRep.AuditTotalResults.Count)
    {
        Assert.Fail("The count of Drivers is " + _AuditRep.AuditResultsByEntity("Users").Count + " whereas "
            + "the total count is " + _AuditRep.AuditTotalResults.Count);
    }
    else
    {
        Console.WriteLine("The count of entity Drivers is " + _AuditRep.AuditResultsByEntity("Users").Count + " and "
            + "the total count is " + _AuditRep.AuditTotalResults.Count);
    }
}

标签: c#selenium-webdriverautomation

解决方案


推荐阅读