单选按钮互动
在本节中,我们将了解如何使用单选按钮交互。我们可以使用“click”方法,并取消选择使用相同的“click”方法选择一个单选按钮的选项。
让我们明白,如何使用单选按钮交互- http://www.calculator.net/mortgage-payoff-calculator.htmll。我们还可以检查是否选择或使能的单选按钮。

import
java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class webdriverdemo
{
public static void main(String[] args) throws
InterruptedException
{
WebDriver driver = new FirefoxDriver();
//Puts a Implicit wait, Will wait for 10
seconds before throwing exception
driver.manage().timeouts().implicitlyWait(10,
TimeUnit.SECONDS);
//Launch website
driver.navigate().to("http://www.calculator.net/mortgage-payoff-calculator.htmll");
driver.manage().window().maximize();
// Click on Radio Button
driver.findElement(By.id("cpayoff1")).click();
System.out.println("The Output of the
IsSelected " + driver.findElement(By.id("cpayoff1")).isSelected());
System.out.println("The Output of the
IsEnabled " + driver.findElement(By.id("cpayoff1")).isEnabled());
System.out.println("The Output of the
IsDisplayed " + driver.findElement(By.id("cpayoff1")).isDisplayed());
driver.close();
//Close the Browser.
driver.close();
}
} |
输出
在执行时,被选中的单选按钮和命令的输出显示在控制台中。

|
1183 次浏览 |
12次 |
|
捐助 |
|
|
|
|
|