求知 文章 文库 Lib 视频 iPerson 课程 认证 咨询 工具 讲座 Model Center   Code  
会员   
要资料
 
 

Selenium教程
Selenium概述
Selenium IDE
Selenium IDE下载
Selenium IDE 工具特点
Selenium IDE测试创建
Selenium IDE测试
Selenium IDE验证点
Selenium - IDE模式匹配
Selenium用户扩展
Selenium IDE- 不同的浏览器
Selenium 环境安装设置
Selenium RC
Selenium - Selenese命令
Selenium Webdriver
Selenium定位器
文本框的相互作用
单选按钮互动
复选框交互
下拉框交互
Synchronization 同步
拖放
键盘操作
鼠标操作
多选择操作
查找所有链接
Selenium测试设计技术
Selenium页面对象模型
使用Excel数据驱动
log4j日志
异常处理
多浏览器测试
捕捉屏幕截图
捕捉视频
Selenium TestNG
Selenium网格
 
 

复选框交互
946 次浏览
7次  

复选框交互

在本节中,我们将了解如何与交互复选框。我们可以使用“click”方法选择入住按钮选项,然后取消选择使用相同的“click”方法。

让我们明白,如何使用交互复选框 - http://www.calculator.net/mortgage-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-calculator.htmll");
driver.manage().window().maximize();

// Click on check Box
driver.findElement(By.id("caddoptional")).click();

System.out.println("The Output of the IsSelected " + driver.findElement(By.id("caddoptional")).isSelected());
System.out.println("The Output of the IsEnabled " + driver.findElement(By.id("caddoptional")).isEnabled());
System.out.println("The Output of the IsDisplayed " + driver.findElement(By.id("caddoptional")).isDisplayed());

driver.close();

}
}

输出

在执行时,该复选框被点击命令后,选中(因为它是默认选中)和命令的输出显示在控制台中。


您可以捐助,支持我们的公益事业。

1元 10元 50元





认证码: 验证码,看不清楚?请点击刷新验证码 必填



946 次浏览
7次
 捐助