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();
}
}