最近研究了一下关键字驱动,感觉很有意思,可以让不会写代码的测试工程师,只填写关键字及定位方式、数值即可以实现自动化,而自动化工程师只需要关注于关键字方法的实现即可,因为在自动化测试中大部分操作都是类似的:查找、点击、输入文本、切换窗口、等待、滑动等,以下是实现方法,此方法同样适用于移动端测试,思想都是想通的:
//关键字方法
package com.keyword;
import java.io.File;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class KeyWordExample {
static WebDriver driver;
WebDriverWait wait;
public void open_Browser(String browserName) {
tr