简体   繁体   中英

element not visible Target invocation exception

I am trying to automate login on DropBox https://www.dropbox.com/chooser ,but still facing issues with element not visible, which is weird, even though if the all page is loaded successfully.

Here is the code for filling the password:

   protected virtual void FillPassword(string password)
    {
        //Password.Clear();
        Password.SendKeys(password);
    }

The last line fails on the Target Invocation Exception. I also wanted to use Password.Clear();, but this was also failing.

Here is the locator for Password:

[CacheLookup, FindsBy(How = How.Name, Using = "login_password")]
protected override IWebElement Password { get; set; }

What is going on? I tried to use wait methods for the page,but it has not helped. Does anyone know why it crashes?

I changed the HTML locator to:

[CacheLookup, FindsBy(How = How.CssSelector, Using = ".text-input-wrapper    [name=\"login_password\"]")]
protected override IWebElement Password { get; set; }

and this works fine. I am not sure why the name selector cannot find it. This is misunderstanding to me. Both approaches should work. Here is the page source of the field element:

<div class="text-input-wrapper">
<input id="pyxl14559" class="password-input text-input-input" type="password" name="login_password">
<label for="pyxl14559" style="">Password</label>
<small class="secondary-label"></small>
<div class="password-caps-indicator">Caps lock is currently on</div>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM