Web页面元素定位-Automation

一、日历日期填写

1.Sendkeys

2.去掉readonly,再Sendkeys:
 
  JavascriptExecutorremoveAttribute = (driver;
   //
remove readonly attribute
    removeAttribute.executeScript( "varsetDate=document.getElementByIdx_x(\"train_date  \ ");
  setDate.removeAttribute('readonly');") ;
3. # js = "document.getElementByIdx_x('txtBeginDate').removeAttribute('readonly')"#1.原生js,移除属性#js ="$('input[id=txtBeginDate]').removeAttr('readonly')"#2.jQuery,移除属性
# js = "$('input[id=txtBeginDate]').attr('readonly',false)"#3.jQuery,
设置为false
#js = "$('input[id=txtBeginDate]').attr('readonly','')"#4.jQuery,设置为空
 driver.execute_script(js)
          注意Frame/IFrame

二、链接Link
//定位元素
WebElement linktest = driver.findElement(By.linkText("百度'));
WebElement linktest1 = driver.findElement(By.partialLinkText("百度'));
//操作元素
linktest.click();

三、输入框textbox
//定位元素
WebElement element = driver.findElement(By.id(" "));
//操作元素
element.sendkeys("百度");

四、按钮button
//定位元素
WebElement button = driver.findElement(By.id(" "));
//操作元素
button.click();
button.isEnabled();

五、下拉选择框Select
//定位元素
Select  selector = new Select(driver.findElement(By.id(" ")));
//操作元素,选择对应的选项
selector.selectByIndex(2);
selector.selectByValue("33");
selector.selectByVisibleText("选项1");

六、选择按钮(单选/多选)Radio Button
//定位元素
String xpath = "//inpute[@type="radio"]"
WebElement rbutton = driver.findElement(By.xpath(xpath));
//操作元素
rbutton.click();
boolean isSelect = rbutton.isSelected();

七、浏览器最大化、前进、后退、刷新
driver.manage().window().maximize();
driver.get("http://www.google.com.hk");
driver.navigate().forward();// 前进
driver.navigate().back();// 后退
driver.navigate().refresh();// 刷新

八、弹出对话框:
对话框类型:警告框、提示框、确认框
http://www.cnblogs.com/TankXiao/p/5260445.html

九、显示等待、隐式等待
http://www.cnblogs.com/TankXiao/p/5246557.html

十、iframe元素处理
http://www.cnblogs.com/TankXiao/p/5237189.html













  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值