2

Console shows below errors :

Starting ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}) on port 12848
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1606582973.595][WARNING]: This version of ChromeDriver has not been tested with Chrome version 87.
Nov 28, 2020 10:32:55 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Exception in thread "main" org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element <input type="submit" value="Send" class="wpcf7-form-control wpcf7-submit button"> is not clickable at point (522, 587). Other element would receive the click: <span class="desktop-text">...</span>
  (Session info: chrome=87.0.4280.66)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'PLANET', ip: '192.168.0.106', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '12.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 87.0.4280.66, chrome: {chromedriverVersion: 86.0.4240.22 (398b0743353ff..., userDataDir: C:\Users\Admin\AppData\Loca...}, goog:chromeOptions: {debuggerAddress: localhost:56606}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: 80bd603f6492d9dc7b4f71d2ae7d5edb
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
    at MailTest.main(MailTest.java:46)

I've tried using waits and Javascript Executor but no luck for this error. Below is my code I am using :

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.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class MailTest {

    public static void main(String[] args) throws InterruptedException {
        // TODO Auto-generated method stub
        
        
        System.setProperty("webdriver.chrome.driver","C:/chromedriver.exe");
        
         WebDriver driver = new ChromeDriver();
        
        driver.get("testUrl");
         
        
        //Maximizing window
         driver.manage().window().maximize();
         
         driver.findElement(By.xpath("//body/div[@id='offer--modal']/div[1]/div[2]/p[1]")).click();
         Thread.sleep(10000);
         
         WebElement Name = driver.findElement(By.xpath("//input[@id='name']"));
         Name.sendKeys("test"); 
         
         WebElement email = driver.findElement(By.xpath("//input[@id='email']"));
         email.sendKeys("[email protected]");
         
         
         WebElement Subject = driver.findElement(By.xpath("//input[@id='subject']"));
         Subject.sendKeys("Testing");
         
         driver.findElement(By.xpath("//span[contains(text(),'Mobile Development')]")).click();
         driver.findElement(By.xpath("//span[contains(text(),'Application Development')]")).click();
         
         driver.findElement(By.xpath("//textarea[@id='message']")).sendKeys("testing for automation");
    
        
     WebElement Sendbutton = driver.findElement(By.xpath("//body/div[4]/div[2]/div[1]/div[1]/div[1]/section[1]/div[1]/form[1]/div[7]/input[1]"));
         JavascriptExecutor executor = (JavascriptExecutor)driver;
         executor.executeScript("arguments[0].click()", Sendbutton);
         
         
        // driver.close();
         
    }

}

Above script works fine till submit button I am trying to get clicked. Also, I feel that maybe the problem is with the xpath of submit button. I am using chropath for finding xpaths.

2
  • Add the html please Commented Nov 28, 2020 at 17:22
  • 1
    @Ghazal shukla If the element’s center point is obscured by another element, an element click intercepted error is returned, Can you check your xpath once or add the html here Commented Nov 29, 2020 at 16:10

2 Answers 2

2

The XPath which you are using is pretty much dynamic and it is never suggested to use the XPath with indexes. There must be some attribute with which you can write the xpath for submit button.

Your xpath could be something like-

> //button[@class='submit']
Sign up to request clarification or add additional context in comments.

Comments

1

Your xpath could be improved to something like:

//input[@value='Send']

But the real problem is this button is blocked (as noted by the ElementClickInterceptedException) by this element:

<span class="desktop-text">...</span>

So we either need to dismiss this window, or we can hide this element by doing this:

JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement element = driver.findElement(By.xpath("//span[@class='desktop-text']"));
js.executeScript("arguments[0].setAttribute('display', 'none')", element);

and then try our click:

WebElement Sendbutton = driver.findElement(By.xpath("//input[@value='Send']"));
Sendbutton.click()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.