小编Meg*_*-90的帖子

如何使用Selenium元素来等待、检查、点击而不会再次找到元素?

我是 Selenium 的新手,之前使用过 Telerik 免费测试框架。问题是我无法理解,如何使用已经用 [FindsBy] 识别的元素来等待、检查和点击。

前任:

    [FindsBySequence]
    [FindsBy(How = How.Id, Using = "container-dimpanel")]
    [FindsBy(How = How.CssSelector , Using = ".btn.btn-primary.pull-right")]
    public IWebElement UpdateButton { get; set; }

    internal void ClickUpdateButton(TimeSpan timeout)
    {
        new WebDriverWait(_driver, timeout).
            Until(ExpectedConditions.ElementIsVisible(By.CssSelector(id));
        UpdateButton.Click();
    }
Run Code Online (Sandbox Code Playgroud)

我希望我的代码等待更新按钮可见,然后单击它。但我只想传递 UpdateButton 元素而不是使用 By 选择器。

  • 不确定 UpdateButton.Enabled 是否会等到它可见。

c# selenium selenium-webdriver

5
推荐指数
1
解决办法
2545
查看次数

标签 统计

c# ×1

selenium ×1

selenium-webdriver ×1