当前位置: 首页 > news >正文

微信的网站开发/品牌策划公司

微信的网站开发,品牌策划公司,自助建站网站系统,wordpress前台如何删除文章注意:只有满足显式等待要求,代码才会向后执行,当显式等待条件未满足时,在设定的最大显式等待时间区间内,会停在当前代码位置进行等待,直到设定的条件被满足,才能继续执行后续的测试逻辑。如果超…
注意:只有满足显式等待要求,代码才会向后执行,当显式等待条件未满足时,在设定的最大显式等待时间区间内,会停在当前代码位置进行等待,直到设定的条件被满足,

才能继续执行后续的测试逻辑。如果超过设定的最大显式等待时间区间,程序会抛出异常,测试用例被认为执行失败。













package jkcs;import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait;public class jdcs {public static void main(String[] args) throws InterruptedException {System.setProperty("webdriver.chrome.bin","‪C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //设置安装路径,防止系统找不到WebDriver driver = new FirefoxDriver();driver.get("http://www.baidu.com");driver.manage().window().maximize();new WebDriverWait(driver,5).until(ExpectedConditions.titleIs("百度一下,你就知道")); //标题是不是“百度一下,你就知道”System.out.println(new WebDriverWait(driver,5).until(ExpectedConditions.titleIs("百度一下,你就知道")));new WebDriverWait(driver,5).until(ExpectedConditions.titleContains("百度一下")); //标题是不是包含“百度一下”System.out.println(new WebDriverWait(driver,5).until(ExpectedConditions.titleContains("百度一下")));driver.quit();} }

执行结果:

true
true

=================================================================================================================

方式二:

package jkcs;import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;public class jdcs 
{public static void main(String[] args) throws InterruptedException {System.setProperty("webdriver.chrome.bin","‪C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");    //设置安装路径,防止系统找不到WebDriver driver = new FirefoxDriver();driver.get("http://www.baidu.com");driver.manage().window().maximize();WebDriverWait wait = new WebDriverWait(driver,10);wait.until(ExpectedConditions.titleIs("百度一下,你就知道"));   //标题是不是“百度一下,你就知道”System.out.println(wait.until(ExpectedConditions.titleIs("百度一下,你就知道")));wait.until(ExpectedConditions.titleContains("百度一下"));  //标题是不是包含“百度一下”System.out.println(wait.until(ExpectedConditions.titleContains("百度一下")));driver.quit();}
}

执行结果:

true
true

=======================================================================================================

方式三:(转载)

package com.test.elementwait;import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;public class ExplicitWait {public static void main(String[] args) {WebDriver driver = new FirefoxDriver();driver.get("http://www.baidu.com");driver.manage().window().maximize();//标题是不是“百度一下,你就知道”new WebDriverWait(driver,5).until(ExpectedConditions.titleIs("百度一下,你就知道"));

//标题是不是包含“百度一下”new WebDriverWait(driver,5).until(ExpectedConditions.titleContains("百度一下"));

//判断该元素是否被加载在DOM中,并不代表该元素一定可见 new WebDriverWait(driver,5).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='kw']")));

//判断元素(定位后)是否可见new WebDriverWait(driver,5).until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@id='kw']"))));

//判断元素是否可见(非隐藏,并且元素的宽和高都不等以0)new WebDriverWait(driver,5).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='kw']")));

//只要存在一个就是trueExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//*[@id='kw']"));

//元素中的text是否包含语气的字符串ExpectedConditions.textToBePresentInElementLocated(By.xpath("//*[@id='kw']"), "百度一下");

//元素的value属性中是否包含语气的字符串ExpectedConditions.textToBePresentInElementValue(By.xpath("//*[@id='kw']"), "***");

//判断该表单是否可以切过去,可以就切过去并返回true,否则放回falseExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("**"));

//判断某个元素是否不存在于DOM或不可见ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@id='kw']"));

//判断元素是否可以点击ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='kw']"));

//等到一个元素从DOM中移除ExpectedConditions.stalenessOf(driver.findElement(By.xpath("//*[@id='kw']")));

//判断某个元素是否被选中,一般用在下拉列表ExpectedConditions.elementToBeSelected(By.xpath("//*[@id='kw']"));

//判断某个元素的选中状态是否符合预期ExpectedConditions.elementSelectionStateToBe(By.xpath("//*[@id='kw']"), true);

//判断某个元素(已定位)的选中状态是否符合预期ExpectedConditions.elementSelectionStateToBe(driver.findElement(By.xpath("//*[@id='kw']")), false);

//判断页面中是否存在alertnew WebDriverWait(driver,5).until(ExpectedConditions.alertIsPresent());//--------------------自定义判断条件-----------------------------WebDriverWait wait = new WebDriverWait(driver, 3);wait.until(new ExpectedCondition<Boolean>() {public Boolean apply(WebDriver driver) {return !driver.findElement(By.xpath("//*[@id='kw']")).getAttribute("class").contains("x-form-invalid-field");}});}}

=====================================================================================================

http://www.lbrq.cn/news/1463491.html

相关文章:

  • 阜宁做网站哪家好/武汉今日头条最新消息
  • 可以做数据图的的网站/免费十八种禁用网站
  • 建设b2b平台/seo交流网
  • 购物网站建设需求模板下载/百度浏览器网页版
  • 中国新闻军事报道/防疫管控优化措施
  • 装修公司做网站热门关键词/seo的主要内容
  • tp5如何在自己网站后台做pv uv统计/广州线上教学
  • 网站报备之后如何建设网站/百度pc网页版
  • 电子商务网站建设资料/电商网页制作教程
  • 国务院办公厅关于加强政府网站建设和管理工作的意见 doc/动态网站的制作与设计
  • 肥乡网站建设/营销战略有哪些内容
  • 青岛网站设计建设/电商平台开发
  • 看广告的收益的app/seo优化与推广招聘
  • wordpress要求配置/好的seo平台
  • 网站建设功能报价单/网络营销推广与策划
  • 有关做聚合物电池公司的网站/百度网盘官方下载
  • 经营性网站备案要求/南京网站制作设计
  • 在网站写小说怎么做封面/重庆seo顾问
  • 建站快车金牌代理商/网站怎么开发
  • 私人网站服务器搭建/浏览器谷歌手机版下载
  • 销售型企业有哪些公司/国外网站seo
  • 全球做网站的公司排名/谷歌chrome官网
  • 重庆网站建设师/seo提升排名
  • 大型建设网站制作/网店seo是什么意思
  • 国外网站国内做好还是国外做/免费的网页入口
  • 做的网站怎样适配手机屏幕/指数基金怎么选
  • 初学者的网站建设/如何推广网上国网
  • easyui 做网站/郑州seo优化外包
  • 哪些网站是python做的/域名解析ip138在线查询
  • 建筑工程发布网站/培训学校招生营销方案
  • 音视频学习(五十):音频无损压缩
  • LangGraph认知篇-Persistence 持久化
  • 【1】WPF界面开发入门—— 图书馆程序:登录界面设计
  • Piriority_queue
  • 【机器学习】“回归“算法模型的三个评估指标:MAE(衡量预测准确性)、MSE(放大大误差)、R²(说明模型解释能力)
  • React ahooks——副作用类hooks之useThrottleFn