How do I get past this login page?

223 Views Asked by At

I need to visit several web pages every day to update a spreadsheet. I'm trying to automate the process. On one site, I can't get past the login page.
No matter what I throw at it, it says I haven't entered anything. If I type one character in and delete it, it works fine.

TextField UserField = FindUsernameField(UsernameField);
UserField.ClickNoWait();
UserField.MouseEnter();
UserField.Value = userID;
UserField.SetAttributeValue("aria-invalid", "false");  // has no affect, still true
string attr = UserField.GetAttributeValue("class");
attr = attr.Replace("invalid", "valid");  // fails as attr is null

UserField.KeyPress();                

TextField PasswordField = FindPasswordField(this.PasswordField);
PasswordField.Click();
PasswordField.TypeText(password);
PasswordField.Change();

FindButton(LoginButton).Click();

There is more error checking, but this is the basic code. As you can see below, it successfully inserts the data. But this one website doesn't acknowledge it.

login failed

The HTML for the field starts like this:

<input class="ods-textfield__input ng-pristine ng-invalid ng-touched" id="ods-input-0" aria-invalid="false" aria-required="false" aria-labelledby="label-input-0" style="padding-left: 3rem;" type="text" placeholder="" odsInput="" data-controlname="username" _ngcontent-qwp-c11="">

and ends like this:

<input class="ods-textfield__input ng-invalid ng-touched ods-textfield__input--error ng-dirty" id="ods-input-0" aria-invalid="true" aria-required="false" aria-labelledby="label-input-0 ods-error-0" style="padding-left: 3rem;" type="text" placeholder="" odsInput="" data-controlname="username" _ngcontent-qrr-c11="">

I expected "required"

But if I manually enter text, I get this:

<input class="ods-textfield__input ng-touched ng-dirty ng-valid" id="ods-input-0" aria-invalid="false" aria-required="false" aria-labelledby="label-input-0" style="padding-left: 3rem;" type="text" placeholder="" odsInput="" data-controlname="username" _ngcontent-qwp-c11="">

UPDATE: I tried getting the class desc and swapping ng-invalid for ng-valid, and setting invalid=false, see above for code.

0

There are 0 best solutions below