Unable to find Html elements

7 posts, 1 answers
  1. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 05 Jun 2015 Link to this post

    Hello, I'm struggling with a problem that doesn't make sense to me. 

    I'm writing some tests (I'm totally new to the testing framework), the first of which consists on login to the site.

    So I'm doing this:

     myManager.ActiveBrowser.NavigateTo(site.LoginURL);

     myManager.ActiveBrowser.WaitUntilReady();

     Thread.Sleep(5000);

     //Find username control
     HtmlInputText usernameControl = myManager.ActiveBrowser.Find.ById<HtmlInputText>("email");
     usernameControl.MouseClick();
     myManager.Desktop.KeyBoard.TypeText(site.DefaultUser.Username);

    //Find password control

     HtmlInputPassword passwordControl = myManager.ActiveBrowser.Find.ById<HtmlInputPassword>("password");

     passwordControl.MouseClick();
     myManager.Desktop.KeyBoard.TypeText(site.DefaultUser.Password);

     Element loginBtn = myManager.ActiveBrowser.Find.ById("loginBtn"); 
     myManager.ActiveBrowser.Actions.Click(loginBtn);

     

     I had to use html elements for the imput boxes because the site is made using ember.js and looks like it requires "real typing".

    The problem is that if I run this against a local testing site it works perfectly. However if I try to run it against a site (an identical copy) on a remote server, the framework can't find the controls and I get a null reference exception because the object "usernameControl" is null.

    I can warranty that the site hosted on the remote server contains those controls, and that's why this doesn't make sense to me. 

    Am I missing something? Any help will be appreciated.

    Thanks in advance,

     

    Gonzalo

  2. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 07 Jun 2015 in reply to gmendez Link to this post

    By the way, forgot to tell that I reviewed all the settings specified for IE. I'm running IE 11 on Windows 8.1. 

    The solution was compiled against .NET 4.5.2.

    Also tryed to use Find.ByName<TControl> but still doesn't work.

    Thanks.

  3. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 10 Jun 2015 Link to this post

    Hello Gonzalo,

    Due to the nature of the problem we will need the test you are executing with access to the tested application in order to determine what is causing the problem. However only from the code and the description provided we are not able to investigate any further.

    Regards,
    Ivaylo
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  4. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 10 Jun 2015 in reply to Ivaylo Link to this post

    Hello Ivaylo,

     Attached you fill find Example.zip. It's a simple console application that fails on finding the textboxes.

    Off course it's trying to access the real url. 

    As I said, I have an identical copy of this site in my computer, which I can run my tests against without problems.

    Cheers!

     Gonzalo

     

     

  5. Answer
    Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 15 Jun 2015 Link to this post

    Hello Gonzalo,

    Thank you for providing me with the repro, I was able to reproduce the behavior easily and easily to fix it, just added the following line:

    myManager.ActiveBrowser.RefreshDomTree();

    and the test never failed afterwards.

    Here is a sample video demonstration(no audio).

    Hope this should work for you as well.


    Regards,
    Ivaylo
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  6. gmendez
    gmendez avatar
    82 posts
    Member since:
    Jun 2012

    Posted 15 Jun 2015 in reply to Ivaylo Link to this post

    Hi Ivailo,

    Thanks a lot for your reply.

    Worked perfectly!

     Cheers!

     Gonzalo

  7. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 18 Jun 2015 Link to this post

    Hello,

    You are most welcome.

    Regards,
    Ivaylo
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
Back to Top