我是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();
}
我希望我的代碼,以等待更新按鈕是可見的,然後點擊它。但我想傳遞UpdateButton元素而不是使用By選擇器。
- 不確定UpdateButton.Enabled是否等到其可見。
感謝提供答案。不幸的是,C#在ExpectedConditions中沒有visibilityOf()方法。相反,它有ElementToBeClickable()。 –
它看起來像圖書館有一個叫ElementIsVisible:https://seleniumhq.github.io/selenium/docs/api/dotnet/html/M_OpenQA_Selenium_Support_UI_ExpectedConditions_ElementIsVisible.htm – nofacade