0

I'm writing testcases to select 7 radio buttons. While select the radio button it displays run time error.

I have tried with below code :

public void selecttemplate()
{
 List<WebElement> rdBtn = driver.findElements(By.name("Template_Type")); 
 int size=rdBtn.size();
 for(int i=0;i<size;i++)
 {
 String val=rdBtn.get(i).getAttribute("value");
 if(val.equals("Documents"))
 {
 rdBtn.get(i).click();
 break;
 }
 }
 WebElement save=driver.findElement(By.name("register-button"));
 save.submit();
}

Below is error snap:

enter image description here

enter image description here

asked Oct 14, 2017 at 9:19
3
  • 2
    Can you provide the html code for the respective elements on which action should be done Commented Oct 14, 2017 at 14:36
  • i have add screenshot please check Commented Oct 16, 2017 at 5:47
  • Can you please put whole error stack trace ? Commented Oct 16, 2017 at 5:59

1 Answer 1

1

As I understand from this stack trace it is issue of Element is not clickable.

For this exception, following problem :

  1. Page is not loaded properly. So you need to wait for page and all component to load. Here is the code :
 public void selecttemplate()
 {
 WebDriverWait wait = new WebDriverWait(driver, 20);
 List<WebElement> rdBtn = driver.findElements(By.name("Template_Type")); 
 int size=rdBtn.size();
 for(int i=0;i<size;i++)
 {
 String val=rdBtn.get(i).getAttribute("value");
 if(val.equals("Documents"))
 {
 // wait - recommended case 
 wait.until(ExpectedConditions.elementToBeClickable(rdBtn.get(i)));
 //Use Thread.sleep(); Not recommended. Use only in last working case 
 //Thread.sleep(4000);
 rdBtn.get(i).click();
 //Thread.sleep(4000);
 break;
 }
 }
 WebElement save=driver.findElement(By.name("register-button"));
 save.submit();
 }

  1. Web Element is not on visible screen or Visible area:
  • Scroll to that element and perform click operation

  1. Some ajax event perform while clicking :
  • Same solution as Point Num : 1

Note : Choose your problem and perform the solution.

answered Oct 16, 2017 at 7:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.