1

Hello I'm trying to login to Skype's site programmatically but the password field cannot be found by selenium. I'm using selenium's webdriver framework in c#

String loginURL = "https://login.skype.com/login?message=signin_continue&client_id=360605&redirect_uri=https%3A%2F%2Fsecure.skype.com%2Fportal%2Flogin%3Freturn_url%3Dhttps%253A%252F%252Fsecure.skype.com";

IWebDriver driver = new FirefoxDriver();
        driver.Navigate().GoToUrl(loginURL);
        IWebElement usrElement = driver.FindElement(By.Id("username"));
        usrElement.Clear();
        usrElement.Click();
        usrElement.SendKeys(usr);
        IWebElement nextBtnElement = driver.FindElement(By.Id("signIn"));
        nextBtnElement.Click();

this works and it enters my username into the box, but when it gets to the next field (the password field) selenium can't find the input form id which on my browser source inspector claims it is "i0118". I've also tried setting the id as "password" and name as "passwd" but no luck. Why can I see it on the browser inspector as "i0118" but my driver object can't even though we are using the same firefox executable?

here is the html code that my browser inspector comes up with

<input name="passwd" id="i0118" autocomplete="off" class="form-control" aria-describedby="passwordError passwordDesc" data-bind="
                textInput: password,
                hasFocusEx: isFocused,
                placeholder: $placeholderText,
                ariaLabel: str['CT_PWD_STR_PwdTB_Label'],
                attr: { maxLength: svr.C ? 127 : null },
                css: { 'has-error': error }" aria-label="Password" maxlength="127" type="password">
3
  • Is it possible for you to get the output of what webdriver is seeing? It is possible that Javascript is unavailable - the login form needs it. Commented Feb 12, 2017 at 23:24
  • Yes it is, when I start debugging my program it actually launches the firefox executable and I see exactly what it's doing on the front end and can inspect the elements and such. Commented Feb 13, 2017 at 0:54
  • I can write the current page source to a file yes, it seems to be different than what is on screen when selenium is automating stuff which is weird, shouldn't it be the same? Commented Feb 13, 2017 at 1:08

1 Answer 1

2

That's because the password field (with ID i0118) is loaded dynamically (e.g. via AJAX) after you enter a username (which is done to validate first that the username exists), so that's probably causing issues with Selenium.

What you can do is run a timer function right after entering the username and clicking the button, that runs every 200 ms and checks for the existence of the password field, which would be loaded once the internal AJAX function in the Skype login page completes, with a maximum number of retries, while also checking in each timed call to the function if the text "That Microsoft account doesn't exist" (which is displayed by the Skype login page when the username doesn't exist) is found in the page to display an alert in the screen indicating the username is not valid.

Sign up to request clarification or add additional context in comments.

3 Comments

I told my program to wait 2 seconds and then it worked!!! Thank to both of you guys for help! That was bleedin genius.
No probs :) However, it's best if you use a timed self-calling (i.e. recursive) function to test for the presence of the password field. If you don't use it and instead use the 2-sec delay, and for some reason the AJAX request in the Skype site takes more than that (which it will), then the login will silently fail.
that's a clever idea

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.