Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 可见但覆盖_Java_Selenium_Xpath_Web Scraping_Wait - Fatal编程技术网

Java 可见但覆盖

Java 可见但覆盖,java,selenium,xpath,web-scraping,wait,Java,Selenium,Xpath,Web Scraping,Wait,我正在使用selenium制作一个脚本,在一个步骤中,它在网页中心显示加载图标。加载图标在执行第1行后出现 test.driver.findElement(By.id("oaapprove")).click(); test.driver.findElement(By.xpath("//*[text()='DATA EXPLORER']")).click(); 第二个元素仍然存在于DOM中,但它不可单击,所以我得到的错误是不可单击 我试过这个: Boolean isPresent=test.d

我正在使用selenium制作一个脚本,在一个步骤中,它在网页中心显示加载图标。加载图标在执行第1行后出现

test.driver.findElement(By.id("oaapprove")).click();
test.driver.findElement(By.xpath("//*[text()='DATA EXPLORER']")).click();

第二个元素仍然存在于DOM中,但它不可单击,所以我得到的错误是不可单击

我试过这个:

Boolean isPresent=test.driver.findElements(By.xpath("//div[@class='spinner-container']")).size() > 0;
    if(isPresent)
    {
        System.out.println("Target element found");
    }
    while(test.driver.findElements(By.xpath("//div[@class='spinner-container']")).size() > 0)
    {
        try {
            System.out.println("inside");
            Thread.sleep(250);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    if(!(test.driver.findElements(By.xpath("//div[@class='spinner-container']")).size() > 0))
    {
        System.out.println("Target element not found");
    }
它一直打印“内部”,直到加载图标可见,但在图标消失后,它不会打印“内部”,而是等待7-8秒,然后执行下一个语句。 等待的原因是什么


请告诉我如何解决这个问题。

如果使用fluentwait显示元素可单击,请尝试操作类:

WebElement yourElement = test.driver.findElement(By.xpath("//*[text()='DATA EXPLORER']"));

Actions act = new  Actions(test.driver);
act.moveToElement(yourElement).click().build().perform();

如果使用fluentwait显示元素可单击,请尝试操作类:

WebElement yourElement = test.driver.findElement(By.xpath("//*[text()='DATA EXPLORER']"));

Actions act = new  Actions(test.driver);
act.moveToElement(yourElement).click().build().perform();

我得到了解决方案,我使用了


我得到了解决方案,我使用了


但是它应该等到加载图标熄灭是的,但是您说的是在执行test.driver.findElement(By.id(“oaapprove”))之后;加载图标熄灭,但它应该等到加载图标熄灭。是的,但您说在执行test.driver.findelelement(By.id(“oaapprove”))之后是NAF。单击();加载图标关闭检查您的解决方案是否正常工作,但即使在加载图标消失后,它仍在等待。这可能意味着您使用加载图标错误地定义了模式。其中的参数10是什么?这是超时。如果等待时间超过10秒,则会出现超时异常检查您的解决方案是否正常工作,但即使加载图标消失,它仍在等待。这可能意味着您使用加载图标错误地定义了模式。其中的参数10是什么?这是超时。如果等待时间超过10秒,则会出现超时异常