3
    <div class="input-container">

                <div class="form-group">
                    <div class="labelContainer">
                        <<p>Current Password<span>*</span></p>
                    </div>
                    <label for="currentPassword" class="sr-only">Current Password</label>
                    <input type="password" id="currentPassword" name="currentPassword" class="form-control" placeholder="Current Password" required="">
                    <i class="fa fa-lock icon-style" aria-hidden="true"></i>
                </div>

                <div class="form-group">
                    <div class="labelContainer">
                        <<p>Enter New Password<span>*</span></p>
                    </div>
                    <label for="newPassword" class="sr-only">New Password</label>
                    <input type="password" id="newPassword" name="newPassword" class="form-control" placeholder="New Password" required="">
                    <i class="fa fa-lock icon-style" aria-hidden="true"></i>
                </div>

                <div class="form-group">
                    <div class="labelContainer">
                        <<p>Confirm New Password<span>*</span></p>
                    </div>
                    <label for="confirmPassword" class="sr-only">Confirm New Password</label>
                    <input type="password" id="confirmPassowrd" name="confirmPassowrd" class="form-control" placeholder="Confirm Password" required="">
                    <i class="fa fa-lock icon-style" aria-hidden="true"></i>
                </div>

Above is the html code, I would like to insert the current password into current password text field. I have tried two methods below and it is not workable it says element not visible.

(code 1 )driver.FindElement(By.Id("currentPassword")).SendKeys("testabc");
(code 2 )IJavaScriptExecutor jse = (IJavaScriptExecutor)driver;
jse.ExecuteScript("document.getElementById('currentPassword').value='testabc';");

Try to test for newPassword textfield instead of currentPassword textfield and it is working fine. only the currentPassword and confirmPassword textfield have error message element not visible.

Does anyone know what is the problem?

5
  • Sometimes you have to &quot;click&quot; into the element first. So try using the &quot;Click()&quot; method on the element directly before the send keys call. Also it sometimes has to be an outer element that you click on so I'd recommend experimenting with that if it doesn't work with the input element for the click event. Commented Aug 15, 2018 at 6:09
  • @CodingKuma tried with click() it still saying element not visible Commented Aug 15, 2018 at 6:15
  • Sounds like there is collapsible forms that you need to expand. Commented Aug 15, 2018 at 15:02
  • Any chance this is in some type of form or something else that you need to switch to first? Commented Aug 15, 2018 at 19:56
  • @Ywapom not sure. first time i facing such problem Commented Aug 16, 2018 at 2:44

1 Answer 1

3

You may try this,

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("currentPassword"))).SendKeys("testabc");
Sign up to request clarification or add additional context in comments.

5 Comments

is not working. Still appear element not visible error message
@Kevin then you should debug your code, And you will find where exactly it is stuck. Might be you will find something else that is causing.
try to debug also. but everytime reach the currentpassword that line is have error. so i guess is obvious is that particular line of code
Still its same exception says "element not visible" ?
yup still the same exception.

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.