js操作

Jack2k發表於2021-09-09

Element is not currently visible and may not be manipulated exception

元素被遮擋,等


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部落格 ” ,連結:http://blog.itpub.net/36/viewspace-2815826/,如需轉載,請註明出處,否則將追究法律責任。