org.openqa.selenium.ElementClickInterceptedException:

370 views
Skip to first unread message

Radhika Joshi

unread,
Mar 25, 2020, 4:00:09 AM3/25/20
to seleniu...@googlegroups.com
Hi team, 
I am using the following code to generate a test by entering username , email and key field. after clicking on Start test, I try to click on Next button (for next question) until the end of the test.
So after printing "Successfully found next button", it shows:Exception in thread "main" org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element <a href="javascript:void(0)" id="next_btn" class="button grey_btn_bg fltLeft order2" onclick="engineupdate('1','1','false','false','0','0','false');" style="display: block;">...</a> is not clickable at point (257, 692). Other element would receive the click: <div class="bg"></div>

The code is as follows. Please suggest. TIA :

public class TestFunction {
public static void main(String args[]) {

System.setProperty("webdriver.chrome.driver", "E://chromedriver.exe");
WebDriver driver= new ChromeDriver();

String baseUrl= "https://assessments.firstnaukri.com/TE/429049185";
driver.get(baseUrl);

driver.manage().window().maximize();

WebElement Master_Key = driver.findElement(By.xpath("//input[contains(@name,'ctl00$ContentPlaceHolder1$txtmasterkey') and @id='ctl00_ContentPlaceHolder1_txtmasterkey']"));
   WebElement Name = driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_txtname']"));
   WebElement Email = driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_txtemail']"));
   WebElement Submit= driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_Button1' and @value='Submit']"));
 
   
   Name.sendKeys("test");  //Enters Username
   Email.sendKeys("te...@gmail.com"); //Enters Email
   Master_Key.sendKeys("soc@123");  //Master Key for the test
   Submit.click();  //Clicks on Submit button
   
   WebDriverWait wait= new WebDriverWait(driver, 20);
   
   WebElement Start_Test= wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[contains(@class, 'start-btn') and @name='btn_redirect']")));
   Start_Test.click(); //Starts the test
   
   WebElement Next_btn= wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@id='next_btn' and contains(@class, 'button')]")));
   System.out.println("Successfully found next button");
   do {
    Next_btn.click();  //To go to Next Question
    System.out.println("Successfully clicked on next button");
    wait.until(ExpectedConditions.visibilityOf(Next_btn));
   }while(Next_btn.isDisplayed());  //while it does not reach end of test
   
   System.out.println("Reached end of test");
   driver.close();
}
}

Regards,
Radhika Joshi

mahesh harish

unread,
Mar 25, 2020, 4:40:55 AM3/25/20
to seleniu...@googlegroups.com
WebDriverWait wait= new webDriver(driver,30):
Wait.until(ExpectedConditions.elementToBeClickable().click():.
Or 
Actions act= new Actions (driver);
act.moveToElement().build(). perform ();
act.click().build(). perform ():
 Can you try this two.let me know
Thanks
Mahesh G 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CALLrrpLDqYzwObp47S_zggdhtf4bkxa039U1q8vshCFT7n-9zA%40mail.gmail.com.

Radhika Joshi

unread,
Mar 25, 2020, 6:16:06 AM3/25/20
to seleniu...@googlegroups.com
It works for me.. thanks !

Regards,
Radhika Joshi

mahesh harish

unread,
Mar 25, 2020, 7:48:53 AM3/25/20
to seleniu...@googlegroups.com

Radhika Joshi

unread,
Mar 25, 2020, 9:14:59 AM3/25/20
to seleniu...@googlegroups.com
Actions class worked for me. Wait was giving ElementClicked Intercepted exception.

Thanks you once again!
Radhika

mahesh harish

unread,
Mar 25, 2020, 11:59:25 AM3/25/20
to seleniu...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages