我收到此错误“ org.openqa.selenium.ElementClickInterceptedException”

时间:2019-07-05 11:41:28

标签: selenium-webdriver

具有div id =“ preload”的

loader重叠了所有基础元素,因此      我无法单击任何元素。为此,我编写了一种方法

// this is the method before clicking on any element i need to call
Test{ 
public  String waitForElementNotVisible(int timeOutInSeconds, WebDriver driver, String elementXPath) { 
    if ((driver == null) || (elementXPath == null) || elementXPath.isEmpty()) { 

        return "Wrong usage of WaitforElementNotVisible()"; 
    } 
    try { 
        (new WebDriverWait(driver, timeOutInSeconds)).until(ExpectedConditions.invisibilityOfElementLocated(By 
        .xpath(elementXPath))); 
        return "null"; 
    } catch (TimeoutException e) { 
        return "Build your own errormessage..."; 
    } 
}

}

i have so many elements i don't want to call this method again and again 
for each 
element..if i wont call this method to each elements before click means i 
will get 
error like  "element click intercepted: Element <a href="http://stage.altechcrm.shrigowri.com/admin/inventory/create" class="btn btn-outline btn-success btn-sm">...</a> is not clickable at point (338, 307). Other element would receive the click: <div class="preloader" style="opacity: 0.733965;">...</div>"


//this is another class ,here i have called that method here only i wrote 
xpath for each element as of now i have 2 xpath

public class InventoryModule extends Test {

public static void main(String[] args) throws InterruptedException {
    //creating object of test class
        Test t1=new Test();

t1.waitForElementNotVisible(50,driver,LoaderXpath);
    driver.findElement(By.xpath("//a[contains(@href,'admin/inventory')]")).click();

    t1.waitForElementNotVisible(50,driver,LoaderXpath);
    driver.findElement(By.xpath("//a[contains(@href,'admin/inventory/create')]")).click();

} }

0 个答案:

没有答案