Search code examples
seleniumselenium-webdriverwebdriverjunit4

How to resolve org.openqa.selenium.WebDriverException?


I am writing an automated test and want to report bugs, if occur, directly in the repo at GitHub. The step which fails in my program is the Submit new issue button from GitHub Issue Tracker.

Here is the code:

WebElement sendIssue = driver.findElement(By.xpath("/html/body/div[5]/div/div/div[2]/div[1]/div/form/div[2]/div[1]/div/div/div[3]/button"));

sendIssue.click();

And the exception:

org.openqa.selenium.WebDriverException: Element is not clickable at point (883, 547.7999877929688). Other element would receive the click: div class="modal-backdrop"></div

The following command also does not work:

((JavascriptExecutor) driver).executeScript("arguments[0].click();", sendIssue);

How can I make it clickable? Is there any other way by which I can resolve this issue?

enter image description here


Solution

  • This is happening because when selenium is trying to click ,the desired element is not clickable.

    You have to make sure that the Xpath provided by you is absolutely right.If you are sure about the Xpath then try the following

    replace

    WebElement sendIssue = driver.findElement(By.xpath("/html/body/div[5]/div/div/div[2]/div[1]/div/form/div[2]/div[1]/div/div/div[3]/button"));
    
    sendIssue.click();
    

    with

    WebElement sendIssue =(WebElement)new WebDriverWait(DRIVER,10).until(ExpectedConditions.elementToBeClickable(By.xpath("/html/body/div[5]/div/div/div[2]/div[1]/div/form/div[2]/div[1]/div/div/div[3]/button")));
    sendIssue.click();
    

    If that doesn't work ,You will get an Timeout exception, In that case try incaresing the timeout amount from 10 to 20.

    If it still doesn't work please post a screenshot of the HTML.

    You need to write something in the issue title and description to make the issue clickable are you sure you are not making that mistake of clicking the button without writing anything in those places I am adding screenshot for your convenience. If you dont enter the valid inputs the element is not clickable