元素被遮挡,等
package test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class buttongroup {
@Test
public void test() throws InterruptedException{
System.setProperty("webdriver.chrome.driver", "D:/01 Learn WebDriver/chromedriver.exe");
WebDriver dr = new ChromeDriver();
dr.manage().window().maximize();
dr.get("file:///C:/Users/fengchuanyun/Desktop/1/%E8%87%AA%E5%8A%A8%E5%8C%96%E7%BB%83%E4%B9%A0/attribute.html");
WebElement el = dr.findElement(By.xpath("//*[@id='tooltip']"));
//((JavascriptExecutor)dr).executeScript("(arguments[0]).click()", el);
((JavascriptExecutor)dr).executeScript("tooltip.click()");
//dr.quit();
}
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/36/viewspace-2815826/ ,如需转载,请注明出处,否则将追究法律责任。