当前位置:网站首页>selenium-webdriver之断言
selenium-webdriver之断言
2022-06-12 14:18:00 【小小微的博客】
测试代码执行之后,如何判断最后的结果是否满足预期值,就涉及到断言,在webdriver,可以通过判断元素的内容是否含有指定内容的方式进行断言,如增加了某一条数据,增加之后,想验证当前页面是否存在这条数据,就通过验证数据列表的第一条的第一项内容是否是预期值

具体代码如下
// 通过先定位元素,再对元素含有的文本进行判断
WebElement check = driver.findElement(By.xpath("/html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/div/div[2]/div[2]/div/div/div/div/div/div/div/table/tbody/tr/td[2]"));
System.out.println("文本内容为:******"+ check.getText());
Assert.assertTrue(check.getText().equals("API01"));
来自 <http://lxw198902165221.blog.163.com/blog/static/25895002220179194104953/>
边栏推荐
- Player actual combat 22 to solve the problems of flower screen and Caton
- QT to realize the simple use of SQLite database
- New technology: efficient self-monitoring visual pre training, local occlusion no longer need to worry!
- 新技术:高效的自监督视觉预训练,局部遮挡再也不用担心!
- Player actual combat 21 audio and video synchronization
- 3. Process concealment under the ring ----- continuous concealment and new opening prevention
- How to use Android studio to create an Alibaba cloud Internet of things app
- In C language, the main function calls another function, which is understood by assembly code
- Player practice 20 unpacking thread
- Player practice 11 audio resampling
猜你喜欢

C語言中主函數調用另外一個函數,匯編代碼理解

Leetcode 2176. 统计数组中相等且可以被整除的数对

Design of PLC intelligent slave station based on PROFIBUS DP protocol

Why do Chinese programmers change jobs?

Program analysis and Optimization - 6 loop optimization

PMP agile knowledge points

G++ error in compiling Win32 program: undefined reference to '__ imp_ GetStockObject‘

JS (II) syntaxerror: cannot use import statement outside a module

Player practice 26 adding slider and window maximization

QT to realize the simple use of SQLite database
随机推荐
Create a slice slice pit using the make method
C secret script Chapter 3 (detailed explanation of string function) (Section 2)
C語言中主函數調用另外一個函數,匯編代碼理解
Huawei equipment configuration BGP as number replacement
C magic skill Chapter 4 (detailed explanation of memory function)
Implementation and debug of process hiding under x64
Shell脚本到底是什么高大上的技术吗?
New technology: efficient self-monitoring visual pre training, local occlusion no longer need to worry!
Crawler problem set (I) record
Interview (XI) futu written test questions
Basic usage of scanner
Des File Encryptor based on MFC framework
Dynamic search advertising intelligent search for matching keywords
Appnium (I) basic use of appnium
Design of PLC intelligent slave station based on PROFIBUS DP protocol
Two methods of implementing asynchronous calling function with QT
Configuring OSPF pseudo connection for Huawei devices
新技术:高效的自监督视觉预训练,局部遮挡再也不用担心!
The original Xiaoyuan personal blog project that has been around for a month is open source (the blog has basic functions, including background management)
How to use Android studio to create an Alibaba cloud Internet of things app