Forum Discussion

Novari-QA's avatar
Novari-QA
Frequent Contributor
7 years ago

Checkpoint to check if an element has been set to focus

I am looking to create a check point at the time of recording so that I can check on page refresh if a textbox has primary focus.. 

In this example, I want to check if the login username textbox is selected at the time of page load.

 

How can this be done? All I can find is the property Autofocus, and that is not what I want.

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Unfortunately, every application and every element potentially does things differently.  Without knowing more specifics as to how your application has been implemented, any answer I give would be a guess, and a rather reaching one at that.

     

    You can look to see if there is a property like "has focus".  I'm looking at a similar page in my AUT and I see that there is an attribute object called "autofocus" for the username field but not one for the password field.  So, I'm assuming (and again, this is a guess) that this is what causes my username field to have focus upon page load.  So... if "autofocus" is present, then I assume that the field has focus.

     

    YMMV... 

     

    Just as a side note..  minor UX items like this don't have a large ROI for automation. The universe will not end and the application will not crash if, during a regression cycle, the username field doesn't have focus.  Spending the time to automate checking for that really does not pay off in the long run because you aren't going to have as much of a problem if this little piece of UX gets missed.  Just as kind of a Best Practice for test automation, no matter what tool you use, while you CAN automate EVERYTHING given enough time and resource, with limitations on resource, you probably SHOULDN'T automate everything... 

     

     

    • Novari-QA's avatar
      Novari-QA
      Frequent Contributor

      Interesting, I never considered the fact that it doesn't need to be automated. It was just one property check so it seemed small enough. 


      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Obviously, if you are tasked to automate it, I'm not your boss so not my job to countermand... however, industry wide there is always that consideration of SHOULD I automate it... will it give me an ROI worth the time investment?  While lots of folks like to automate every little UI check, I typically steer clear because, as a human being, if I load up a web page, I can see pretty quickly (like within a couple of seconds) where the problems are on the page.  Meanwhile, writing automation code to check all properties aginst particular values and alignments and tab stops and fonts and so forth.... that's a lot of code for not a lot of benefit.  UX is important for software, but it won't cause the stock market to crash if the banking app doesn't have the right font when the new release goes out... ;)