本篇介绍,自动化测试中关于断言部分,可能经常遇到的场景。从一个字符串中找出一组数字。这个就需要用到字符串切片函数split()。看看这个场景:
1. 百度搜索输入 anthony_tester
2.点击查询,观察结果
3. 观察红圈元素的xpath表达式
需要做的事情是:摘取出40,100这个数字。
相关selenium自动化脚本如下
package lessons;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class StringOpration {
public static void main(String[] args) throws InterruptedException {