如何实现已打开页面控制,我是参考https://blog.csdn.net/liang1352389/article/details/104392578的
isExist这个方法是我用来判断是否存在页面元素的,页面标题能够获取正确,我想要点击的按钮也是判断为存在的,可就是点击不了,也没有报错,这是什么原因呢?
public class autotestRun {
//执行操作
public static void main(String[] args) throws Exception {
System.setProperty("webdriver.chrome.driver", ".\\driver\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
WebDriver driver = new ChromeDriver(options);
CreateOutpFiles c1 = new CreateOutpFiles(driver);
}
public class CreateOutpFiles {
//点击操作
public CreateOutpFiles(WebDriver driver) throws InterruptedException{
String handle1 = driver.getWindowHandle();
System.out.println(driver.getTitle());
System.out.println(BasicConfig.isExist(driver,By.xpath("//*[@id='app']/div/div[2]/div/div[1]/div[1]/div/div/div[1]/div[1]/button"),1));
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='app']/div/div[2]/div/div[1]/div[1]/div/div/div[1]/div[1]/button")).click();
driver.quit();
}
}