How to check if an element is visible with WebDriver

后端 未结 11 1579
臣服心动
臣服心动 2020-12-04 13:14

With WebDriver from Selenium 2.0a2 I am having trouble checking if an element is visible.

WebDriver.findElement returns a WebElement<

11条回答
  •  囚心锁ツ
    2020-12-04 13:40

    If you're using C#, it would be driver.Displayed. Here's an example from my own project:

    if (!driver.FindElement(By.Name("newtagfield")).Displayed)      //if the tag options is not displayed
        driver.FindElement(By.Id("expand-folder-tags")).Click();    //make sure the folder and tags options are visible
    

提交回复
热议问题