How to verify element present or visible in selenium 2 (Selenium WebDriver)

前端 未结 7 795
星月不相逢
星月不相逢 2020-11-29 18:41

Any one can send me sample code how to verify element

  1. ispresent
  2. isvisible
  3. isenable
  4. textpresent

in Se

相关标签:
7条回答
  • 2020-11-29 19:04

    You could try something like:

        WebElement rxBtn = driver.findElement(By.className("icon-rx"));
        WebElement otcBtn = driver.findElement(By.className("icon-otc"));
        WebElement herbBtn = driver.findElement(By.className("icon-herb"));
    
        Assert.assertEquals(true, rxBtn.isDisplayed());
        Assert.assertEquals(true, otcBtn.isDisplayed());
        Assert.assertEquals(true, herbBtn.isDisplayed());
    

    This is just an example. Basically you declare and define the WebElement variables you wish to use and then Assert whether or not they are displayed. This is using TestNG Assertions.

    0 讨论(0)
提交回复
热议问题