Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

State of the Se (15) object

Shulou Source: shulou.com Published: 2022-06-03 07:11:59 09月23日 Update

Package test

Import org.openqa.selenium.By

Import org.openqa.selenium.NoSuchElementException

Import org.openqa.selenium.WebDriver

Import org.openqa.selenium.WebElement

Import org.openqa.selenium.chrome.ChromeDriver

Import org.testng.annotations.Test

Public class buttongroup {

@ Test

Public void test () {

System.setProperty ("webdriver.chrome.driver", "DJV 01 Learn WebDriver/chromedriver.exe")

WebDriver dr = new ChromeDriver ()

Dr.manage (). Window (). Maximize ()

Dr.get ("file:///C:/Users/fengchuanyun/Desktop/1/%E8%87%AA%E5%8A%A8%E5%8C%96%E7%BB%83%E4%B9%A0/status.html");"

/ / isExist

Try {

WebElement el = dr.findElement (By.id ("12345"))

System.out.println ("the element is E1")

} catch (NoSuchElementException e) {

System.out.println ("no such element E1")

}

Try {

WebElement e2 = dr.findElement (By.name ("user"))

System.out.println ("the element is e2")

} catch (NoSuchElementException e) {

System.out.println ("no such element e2")

}

/ / isDisplayed

WebElement E3 = dr.findElement (By.name ("radio"))

If (e3.isDisplayed ()) {

System.out.println ("E3 display")

}

Else {

System.out.println ("E3 does not display")

}

/ / isEnabled

WebElement e4 = dr.findElement (By.name ("user"))

If (e4.isEnabled ()) {

System.out.println ("e4 available")

}

Else {

System.out.println ("error, E4 not available")

}

/ / isSelected

WebElement e5 = dr.findElement (By.name ("radio")

If (e5.isSelected ()) {

System.out.println ("E5 selected")

}

Else {

System.out.println ("error, not selected")

}

/ / dr.quit ()

}

}

Tags: Object statu Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL MariaDB Redmi Huawei