Waruna Gunaratne Waruna Gunaratne - 1 year ago 129
CSS Question

How to resolve “Element not visible” error shows for only one element in the popup.

All the attributes in same form but script reach to last element shows "element not visible error"

All the elements in same level div tags but script runs the click event (Signup Button) shows Error message “element not visible”. However except submit button click, all the other fields i can populate data in the it and able run the click event also, works in popup window. problem i have popup i added screenshot image.

HTML code here

<form id="sighUpForm" class="form-signin ng-pristine ng-invalid ng-invalid-required ng-valid-pattern" novalidate="" name="sighUpForm">
<div class="row">
<div class="form-group">
<div class="form-group">
<div class="row">
<div class="form-group">
<label class="ng-bind-htmling" ng-bind-html="translation.signup_mobile">Mobile No.</label>
<div class="input-group">
<span class="error-msg ng-hide" style="color:red" ng-show="sighUpForm.PhoneNo.$invalid && submitted">
<div style="text-align:center;">
<label class="checkbox-inline ng-bind-htmling" style="line-height:1.8; font-size:12px">
<input class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" type="checkbox" value="" ng-model="user.termAndCondition" required="" name="termAndcondition" style="height:15px; width:15px; margin-top:5px; margin-right:3px "/>
I agree to the
<a data-target="#tandcmodal" data-toggle="modal" href="#">
<a data-target="#ppmodal" data-toggle="modal" href="#">
<div class="text-center">
<!-- <small class="tc-text">By signing up, you agree to our <a href="#" data-toggle="modal" data-target="#tandcmodal">Terms &amp; Condions</a> and <a href="#" data-toggle="modal" data-target="#ppmodal">Privacy Policy</a></small><br />-->
<!--<button id="submitSignup" type="submit" ng-click="SignUpUser()" class="button signup-btn">Signup</button>-->
<a id="submitSignup" class="button signup-btn" ng-click="SignUpUser()">

Selenium Code Here :-

//Enter PhoneNumber

//Click Agree Tick

//Click Submit button

Popup image :-

enter image description here

Answer Source

You should try using WebDriverWait to wait until element visible and clickable.

You can submit your form here in the following two ways :-

WebDriverWait wait = new WebDriverWait(driver,10);
  • You can use .submit() to submit the form as :-

    WebElement form = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("sighUpForm")));
  • You can use .click() to click on sign up button to submit the form as :-

    WebElement signUp = wait.until(ExpectedConditions.elementToBeClickable(By.id("submitSignup")));

Edited:- It might be possible there are multiple signUp button with id submitSignup and unfortunately you'r interacting with hidden button, you should try to find all element with the id signUp and click on visible one as below :-

List<WebElement> signUpButtons = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id("submitSignup")));
for(WebElement signUp : signUpButtons)
  if(signUp.isDisplayed() && signUp.isEnabled())
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download